中文 | English
An Astro multi-language blog template forked from astro-i18n-starter. Site URL, title, author, and other key info are configured via environment variables for easy multi-environment deployment and reuse across different sites.
en / zh-cn).envsearch-index.json or Algolia (optional)Clone or download this repo
Install dependencies
npm install
Configure environment variables
cp .env.example .env
Edit .env and set at least:
PUBLIC_SITE_URL: Full site URL (e.g. https://example.com)PUBLIC_SITE_TITLE_EN / PUBLIC_SITE_TITLE_ZH_CN: Site titlePUBLIC_SITE_DESCRIPTION_EN / PUBLIC_SITE_DESCRIPTION_ZH_CN: Site descriptionPUBLIC_AUTHOR_NAME: Default author nameSee .env.example for other variables (Giscus, Algolia, GA, social links, etc. are optional).
Run locally
npm run dev
Build
npm run build
Preview build
npm run preview
| Path | Description |
|---|---|
src/blog/en/, src/blog/zh-cn/ | Blog MDX files, organized by language |
src/consts.ts | Site copy and constants; title/description/author read from env, rest editable here |
src/data/projects.ts | Projects page data |
src/locales.ts | Language list and default locale |
.env / .env.example | Environment variables (site, author, third-party services) |
Create a .mdx under src/blog/en/ or src/blog/zh-cn/ with frontmatter like:
---
title: "Post Title"
description: "Short description"
date: 2025-01-01T00:00:00.000Z
updated: 2025-01-15T00:00:00.000Z # optional
author: "Author Name" # optional; falls back to PUBLIC_AUTHOR_NAME
tags: ["tag1", "tag2"] # max 3
series: ["Series Name"] # optional
categories: ["Category"] # optional
---
CLOUDFLARE_API_TOKEN etc., use .github/workflows/deploy-cloudflare.yml or run npm run deploy locally (requires wrangler logged in)..github/workflows/gh-pages.yml; push to main to publish to the gh-pages branch.Ensure CI can read PUBLIC_SITE_URL and other variables (e.g. in GitHub Actions “Settings → Secrets and variables → Actions”, or by injecting them in the workflow).
Same as upstream and this template (see LICENSE or copyright in the repo). Content of sites generated from this template is owned by their respective authors.