Astro启动器

astro-gov-starter — Astro 启动器模板

作者 ctrimm

面向政府服务网站的 Astro 启动模板,内置 USWDS 设计系统、无障碍默认配置、双语路由与 CI 质量门禁。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

3 个预览视图
桌面端首页1 / 3
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 3

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-03查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

以 SCSS 方式引入 USWDS 3.x,不重新实现设计系统组件

02

每个页面默认包含 USA Banner 与 USA Identifier 必需组件

03

按 Section 508 / WCAG 2.1 AA 组织跳转导航、地标与焦点管理

04

英文(/)与西班牙文(/es/)双语路由,一份页面文件服务两个语言

05

Pagefind 静态搜索,构建后索引 dist/,按 html lang 分语言检索

06

CI 质量门禁覆盖 TypeScript、HTML、axe-core、Lighthouse、链接、平实语言与 USWDS 合规

模板详细介绍

这是一个面向政府公共服务网站的 Astro 启动模板,仓库采用 MIT 许可。模板把美国联邦政府设计系统 USWDS 3.x 以 SCSS 方式直接引入,而不是重新实现组件样式,并默认在每个页面放置 USA Banner 与 USA Identifier 两个必需组件。

在无障碍方面,模板按 Section 508 / WCAG 2.1 AA 组织页面结构,包含跳转导航、地标区域和焦点管理;CI 中运行 axe-core 与 Lighthouse 检查。内容层面提供 Services、Announcements、FAQs 三个 Zod 类型化的内容集合,支持 MDX,并内置英文(/)与西班牙文(/es/)双语路由,每个页面只写一份路由文件即可服务两个语言。站点搜索使用 Pagefind,在构建后索引 dist/ 生成静态索引,按页面 html lang 分语言检索,不产生第三方请求。

仓库附带若干本地脚本:init-agency.mjs 用于一次性配置机构名称、域名和 USA Identifier 链接;plain-language.mjs 以 Flesch-Kincaid 平均年级 ≤ 8 作为可读性门槛;compliance-check.mjs 检查构建产物中是否包含 banner、identifier 和跳转导航。输出为纯静态站点,可部署到 GitHub Pages、Cloud.gov Pages、Netlify、Vercel 或对象存储。

需要注意的限制:联系表单与资格筛查页面只是无障碍脚手架,默认不向任何后端提交,需要自行接入 Formspree、API Gateway 等服务;README 提到 GitHub Pages 不支持自定义 HTTP 响应头,public/_headers 中的安全头在该平台会被忽略,需要部署到支持响应头的主机或在前置 CDN 设置;搜索仅在 pnpm build 后的生产构建中可用,开发服务器没有索引。README 中出现的 Astro 版本号与 Node 版本要求属于仓库自身说明,本介绍不据此判断其生产就绪程度。

Astro启动器

适合你的项目吗?

适用场景

  • 需要按 USWDS 规范搭建政府公共服务门户的团队
  • 需要同时提供英文与西班牙文页面的机构站点
  • 希望用静态输出部署到 GitHub Pages、Cloud.gov Pages 或对象存储的项目
  • 需要在 CI 中持续检查无障碍、可读性与 USWDS 合规的站点

适合人群

  • 熟悉 Astro 与内容集合、希望从既有脚手架起步的前端开发者
  • 需要以 USWDS 为设计基础、避免自行维护组件样式的政府项目团队
  • 有双语或多语言内容需求、需要按语言分别检索的站点维护者
  • 希望在构建流程中固定无障碍与平实语言门槛的组织

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    运行 pnpm install 后执行 node scripts/init-agency.mjs 配置机构名称、域名与 USA Identifier 链接

  2. 2

    联系表单与 /apply/* 筛查页面默认不提交,需按代码中的 TODO (M3) 注释接入后端服务

  3. 3

    搜索仅在 pnpm build 后的生产构建中可用,开发服务器没有索引

  4. 4

    GitHub Pages 不支持自定义响应头,public/_headers 中的安全头需改用支持响应头的主机或前置 CDN

  5. 5

    新增语言需同步修改 astro.config.mjs 的 LOCALES、src/i18n/utils.ts 的类型与翻译映射,以及各页面 copy 对象

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 使用该模板需要 Node.js 22.12 或更高版本,并使用 pnpm 10 作为包管理器。
  • 联系表单与资格筛查页面仅为无障碍脚手架,默认不向任何后端提交数据,上线前必须自行接入表单服务或后端。
  • 站点搜索仅在执行 pnpm build 后的生产构建中可用,开发服务器没有搜索索引。
  • 部署到 GitHub Pages 时 public/_headers 中的安全响应头会被忽略,需改用支持自定义响应头的主机或在前置 CDN 设置。
  • 代码采用 MIT 许可,但种子内容单独以 CC0 授权,二者许可范围不同,需分别遵守。
  • README 提及 Formspree 表单服务;真实提交需配置服务端点,其使用额度与费用需单独核对。
  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

Requires **Node.js 22.12 or newer** and **pnpm 10**.

README 原文

The contact form (`/contact/`) and eligibility screeners (`/apply/*`) are **accessible scaffolding only** — they do not submit anywhere out of the box.

README 原文

Search only works on a **production build** (`pnpm build && pnpm preview`); the dev server has no index.

README 原文

GitHub Pages does **not** support custom HTTP response > headers, so the headers in `public/_headers` (clickjacking protection via > `frame-ancestors`, `X-Frame-Options`, HSTS, etc.) are silently ignored on > GitHub Pages.

README 原文

Seed content: CC0 — no rights reserved, free to adapt for any agency.

README 原文
https://github.com/ctrimm/astro-gov-starter/blob/main/LICENSEhttps://github.com/ctrimm/astro-gov-starter/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-03。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
Astro Themes
资料与维护参考分
资料较完整 · 87 / 100
技术栈
Astro
网站类型
启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-08-23
截图检查日期
2026-10-03

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Astro。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: [email protected] · 2026-10-04

查看当时使用的来源资料

SHA-256: 581f8b2660c995439e507137bd95de78fbde6c4adb08e43f16b205763090bfba

2026-10-03T13:43:38.409Z

来源文件 / 仓库
# astro-gov-starter

> A production-ready [Astro 7](https://astro.build) starter template for government service websites.

[![CI](https://github.com/ctrimm/astro-gov-starter/actions/workflows/ci.yml/badge.svg)](https://github.com/ctrimm/astro-gov-starter/actions/workflows/ci.yml)
[![USWDS 3.x](https://img.shields.io/badge/USWDS-3.x-0050d8)](https://designsystem.digital.gov/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)
[![Release](https://img.shields.io/github/v/release/ctrimm/astro-gov-starter?sort=semver)](https://github.com/ctrimm/astro-gov-starter/releases/latest)

**USWDS-native · Section 508 / WCAG 2.1 AA · i18n (en + es) · Zero client JS · Deploy anywhere**

---

<img width="2619" height="2157" alt="pretty_snap_2026_3_18_6_15" src="https://github.com/user-attachments/assets/f7c5085c-6fe2-4aac-9f37-a3eda91f597d" />

---

## Use this template

Requires **Node.js 22.12 or newer** and **pnpm 10**.

Click **"Use this template"** on GitHub to create your own repository, then run the setup wizard:

```bash
pnpm install
node scripts/init-agency.mjs   # configure your agency name, domain, and identifier links
pnpm dev
```

Your site will be at `http://localhost:4321`.

### Pick a release

Every release line targets one major Astro version. Start from the newest line
for the Astro version you want to build on:

| Starter release | Astro | Node | Notes |
|---|---|---|---|
| [`v3.x`](https://github.com/ctrimm/astro-gov-starter/releases/latest) | Astro 7 | ≥ 22.12 | **Current** — bilingual seed content, translatable collections |
| [`v2.x`](https://github.com/ctrimm/astro-gov-starter/releases/tag/v2.1.0) | Astro 7 | ≥ 22.12 | Superseded by v3.x; English-only seed content |
| [`v1.x`](https://github.com/ctrimm/astro-gov-starter/releases/tag/v1.0.0) | Astro 6 | ≥ 18.17.1 | Maintenance only |

Two lines target Astro 7 because v3.0.0 made a breaking change of its own — see
[Upgrading from 2.x](./CHANGELOG.md#upgrading-from-2x). New projects should start
from `v3.x`.

```bash
# start from a specific release instead of the default branch
git clone --branch v3.0.0 --depth 1 https://github.com/ctrimm/astro-gov-starter.git
```

See [CHANGELOG.md](./CHANGELOG.md) for what changed in each release, and
[RELEASING.md](./RELEASING.md) for how releases are cut.

---

## What's included

| Category | Details |
|---|---|
| **Design system** | [USWDS 3.x](https://designsystem.digital.gov/) via SCSS — no reimplementation |
| **Accessibility** | Section 508 / WCAG 2.1 AA — skip nav, landmarks, focus management |
| **Required components** | USA Banner + USA Identifier on every page |
| **Component library** | 20 thin Astro wrappers for USWDS patterns |
| **i18n** | English (`/`) and Spanish (`/es/`) — one route file per page serves both locales |
| **Search** | [Pagefind](https://pagefind.app/) static search at `/search/` — self-hosted, language-aware |
| **Content collections** | Services, announcements, FAQs — Zod-typed, MDX-ready |
| **CI quality gates** | TypeScript, HTML, axe-core, Lighthouse, links, plain language, USWDS compliance |
| **Output** | Static — deploys to GitHub Pages, Cloud.gov Pages, Netlify, Vercel, S3 |

---

## Quick start (from template)

1. Click **Use this template** → **Create a new repository**
2. Clone your new repo and install:
   ```bash
   git clone https://github.com/YOUR-ORG/YOUR-REPO.git
   cd YOUR-REPO
   pnpm install
   ```
3. Run the agency setup wizard:
   ```bash
   node scripts/init-agency.mjs
   ```
   This updates `src/config/site.ts` with your agency name, domain, and the
   seven required [USA Identifier](https://designsystem.digital.gov/components/identifier/) links.
4. Replace seed content in `src/content/` with your programs and FAQs.
5. `pnpm dev` — live preview at `http://localhost:4321`
6. `pnpm build` — production build in `dist/`

---

## Configuration

All agency-specific settings live in one file:

```ts
// src/config/site.ts
export const siteConfig = {
  name: 'Department of Human Services',
  shortName: 'DHS',
  domain: 'dhs.state.gov',
  description: 'Programs and services for eligible residents.',
  locale: 'en-US',

  // Required links for the USA Identifier footer component
  links: {
    about: '/about/',
    accessibility: '/accessibility/',
    foia: 'https://www.foia.gov/',
    noFear: 'https://www.eeoc.gov/no-fear-act-data',
    oig: 'https://www.oversight.gov/',
    privacy: '/privacy/',
    budget: '/',
    usagov: 'https://www.usa.gov/',
  },
} as const;
```

---

## Project structure

```
src/
├── config/site.ts              # Agency name, domain, identifier links ← edit this first
├── content/                    # Markdown content (services, faqs, announcements)
├── components/uswds/           # 20 USWDS pattern wrappers (Alert, Accordion, Hero, …)
├── i18n/                       # Translation strings (en, es) + useTranslations helper
├── layouts/                    # BaseLayout, ServiceLayout, ApplyLayout
├── pages/
│   ├── [...lang]/              # One route file per page serves BOTH / and /es/
│   │   ├── index.astro         #   (locale comes from getStaticPaths via localeStaticPaths())
│   │   ├── services/           #   services index + [slug] detail pages
│   │   ├── apply/[program].astro
│   │   └── search.astro        #   Pagefind-powered site search
│   ├── 404.astro
│   └── internal/components.astro  # Dev-only component preview (not linked publicly)
└── styles/
    ├── uswds-theme.scss         # USWDS entry point (settings + full import)
    └── globals.css              # Tailwind utilities + custom CSS
scripts/
├── init-agency.mjs             # One-time agency setup wizard
├── setup-uswds.mjs             # Copies USWDS assets to public/uswds/
├── plain-language.mjs          # Flesch-Kincaid readability gate (avg grade ≤ 8)
├── compliance-check.mjs        # USWDS compliance check on built HTML
└── check.sh                    # Runs all local quality gates
```

---

## USWDS component library

All 20 components live in `src/components/uswds/`. Preview them at `/internal/components/` during local dev.

| Component | USWDS pattern |
|---|---|
| `Alert` / `SiteAlert` | [Alert](https://designsystem.digital.gov/components/alert/) |
| `Accordion` / `AccordionItem` | [Accordion](https://designsystem.digital.gov/components/accordion/) |
| `Breadcrumb` | [Breadcrumb](https://designsystem.digital.gov/components/breadcrumb/) |
| `CallToAction` | [Banner section pattern](https://designsystem.digital.gov/patterns/) |
| `Footer` | [Footer](https://designsystem.digital.gov/components/footer/) |
| `Header` | [Header](https://designsystem.digital.gov/components/header/) |
| `Hero` | [Hero](https://designsystem.digital.gov/components/hero/) |
| `Pagination` | [Pagination](https://designsystem.digital.gov/components/pagination/) |
| `ProcessList` / `ProcessListItem` | [Process list](https://designsystem.digital.gov/components/process-list/) |
| `Search` | [Search](https://designsystem.digital.gov/components/search/) |
| `ServiceCard` | [Card](https://designsystem.digital.gov/components/card/) |
| `SideNav` | [Side navigation](https://designsystem.digital.gov/components/side-navigation/) |
| `StepIndicator` | [Step indicator](https://designsystem.digital.gov/components/step-indicator/) |
| `SummaryBox` | [Summary box](https://designsystem.digital.gov/components/summary-box/) |
| `Tag` | [Tag](https://designsystem.digital.gov/components/tag/) |
| `USABanner` | [Banner](https://designsystem.digital.gov/components/banner/) |
| `USAIdentifier` | [Identifier](https://designsystem.digital.gov/components/identifier/) |

---

## Quality gates

Run all checks locally before pushing:

```bash
bash scripts/check.sh           # TypeScript + build + HTML + plain language + compliance
bash scripts/check.sh --verbose # same, with per-file output
```

| Gate | Tool | Threshold |
|---|---|---|
| TypeScript | `astro check` | 0 errors |
| HTML | `html-validate` | 0 errors |
| Accessibility | `@axe-core/cli` (CI only) | 0 violations |
| Lighthouse | `@lhci/cli` (CI only) | perf ≥ 90, a11y = 100, BP ≥ 90, SEO ≥ 90 |
| Links | `linkinator` (CI only) | 0 broken internal links |
| Plain language | `scripts/plain-language.mjs` | avg Flesch-Kincaid grade ≤ 8 |
| USWDS compliance | `scripts/compliance-check.mjs` | banner + identifier + skip nav present |

---

## Deploy

### GitHub Pages (included)

Push to `main`. The workflow in `.github/workflows/deploy-pages.yml` deploys automatically.
Enable Pages: **Settings → Pages → Source: GitHub Actions**.

> **⚠️ Security headers:** GitHub Pages does **not** support custom HTTP response
> headers, so the headers in `public/_headers` (clickjacking protection via
> `frame-ancestors`, `X-Frame-Options`, HSTS, etc.) are silently ignored on
> GitHub Pages. They only take effect on Netlify or Cloudflare Pages. If you need
> these protections — and production government sites should have them — deploy
> to a host that supports response headers, or put a CDN/reverse proxy (e.g.
> CloudFront) in front of Pages and set the headers there.

### Cloud.gov Pages

```yaml
# federalist.json
{
  "build": {
    "command": "pnpm install && pnpm build",
    "destination": "dist"
  }
}
```

### Netlify / Vercel

Both auto-detect Astro. Set **build command** to `pnpm build` and **publish directory** to `dist`.

### Any static host (S3, CloudFront, Azure Blob)

```bash
pnpm build   # outputs to dist/
```
Upload the contents of `dist/` to your bucket or CDN origin.

---

## Search

Site search is powered by [Pagefind](https://pagefind.app/). The `pnpm build`
script indexes `dist/` after the Astro build and writes the index to
`dist/pagefind/`. Results are served at `/search/` (English) and `/es/search/`
(Spanish) — Pagefind splits the index by each page's `<html lang>`, so each
locale searches its own content.

- Search only works on a **production build** (`pnpm build && pnpm preview`);
  the dev server has no index.
- The CSP includes `'wasm-unsafe-eval'` because Pagefind runs its index as
  same-origin WebAssembly (this does **not** allow JavaScript `eval()`).
- No third-party requests: the index and UI are self-hosted static files.

---

## Forms

The contact form (`/contact/`) and eligibility screeners (`/apply/*`) are
**accessible scaffolding only** — they do not submit anywhere out of the box.
Before launch, wire the `action` attributes to your backend of choice
(Formspree, API Gateway + Lambda, your agency's form service, etc.). Look for
the `TODO (M3)` comments in `src/pages/[...lang]/contact.astro` and
`src/pages/[...lang]/apply/[program].astro`.

---

## Adding a new language

The template ships with English (`/`) and Spanish (`/es/`). Every page lives
once in `src/pages/[...lang]/` and renders for each locale returned by
`localeStaticPaths()`, so there is no page tree to mirror. To add another
language (e.g. French):

1. Add `fr: 'fr-FR'` to `LOCALES` in `astro.config.mjs`
2. In `src/i18n/utils.ts`: add `'fr'` to the `Locale` type and `locales`
   array, add a `fr` entry to `localeMeta` (native label + og:locale), and
   register `fr.json` in the `translations` map
   (create `src/i18n/fr.json` by copying `en.json` and translating)
3. Add a `fr` entry to each page's `copy` object in
   `src/pages/[...lang]/*.astro` — TypeScript will point you at every one
4. Translate the content collections (see below)

That's it — the header's language selector, hreflang tags, and og:locale
meta tags all read from `locales`/`localeMeta`, so they update automatically
(the header even switches from a simple toggle link to the USWDS dropdown
once there are 3+ locales).

### Translating content

Collection entries are translated by adding a **locale subdirectory** beside
the default-locale files, so translators edit real Markdown instead of strings
crammed into frontmatter:

```
src/content/services/snap.mdx        # English (default locale)
src/content/services/es/snap.mdx     # Spanish
src/content/services/fr/snap.mdx     # French
```

Both files describe the same service, share the URL slug `snap`, and translate
everything — `title`, `summary`, `eligibility`, `keyFacts`, and the body prose.
Keep `applySlug`, `order`, and `related` identical across a set, since those are
identifiers rather than copy.

**Translations are optional.** A page renders the requested locale's file when
one exists and falls back to the default locale otherwise, so a partial
translation ships fine and a missing file never breaks the build. The lookup
lives in `entriesForLocale()` in `src/utils/content.ts`.

The plain-language gate scores each file with a formula built for the language
it is written in — Flesch-Kincaid for English, Fórmula de Crawford for Spanish —
because running an English readability formula over Spanish would fail plain
translations for having longer words. Add a formula there when you add a
language, or its files will be scored as English.

---

## Compliance

See [COMPLIANCE.md](./COMPLIANCE.md) for Section 508, WCAG 2.1 AA, 21st Century IDEA Act,
and USWDS version details.

---

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md).

## License

Code: [MIT](./LICENSE)  
Seed content: CC0 — no rights reserved, free to adapt for any agency.
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。