Building a bilingual site with Astro
Astroi18nStatic Site
Notes on how this site is built, for future maintenance.
Stack
- Astro 5: content-first static site framework
- i18n:
locales: ['zh', 'en']inastro.config.mjs, every language gets a prefix (/zh/,/en/) - Content collections: bilingual folders
src/content/posts/{zh,en}/, with alocalefield in frontmatter
Translation pairing
Translations share the same filename (slug) and point to each other via the translationOf field. The page automatically finds the counterpart and shows a language switcher link.
Deployment
A GitHub Actions workflow builds and publishes to Pages (see .github/workflows/deploy.yml). The root path / redirects to /zh/.