← Return to Log
🚀 AstroWind [03] /ja /en Multilingual Structure (Nav, Layout, Canonical)
• P-chan •
AstroWind DevLog PochomLab
■ AstroWind Series
- 🚀 AstroWind [01] Initial Setup
- 🚀 AstroWind [02] Anchor Scroll Navigation
- 🚀 AstroWind [03] /ja /en Multilingual Structure (Nav, Layout, Canonical)
- 🚀 AstroWind [04] Google Analytics 4 with Consent Mode
■ Purpose
In an AstroWind-based site, separate Japanese and English using the /ja/ and /en/ directories, allowing the following elements to be managed independently for each language:
- Navigation (Header / Footer)
- Layout (loaded navigation and text)
- SEO (canonical / hreflang / html lang)
■ Background
- Pages are separated by language using
/ja/and/en/directories. - Navigation is split into
navigation-ja.tsandnavigation-en.ts. - Page layouts are separated into
PageLayout_Ja.astroandPageLayout_En.astro, switching which navigation file is loaded.
■ Pull Request
https://github.com/pochomlab/pochomlab-astrowind-lab/pull/3
■ Implementation
- Separated pages under
/jaand/en. - Added
navigation-ja.tsandnavigation-en.ts. - Split layouts into
PageLayout_Ja.astroandPageLayout_En.astro, switching the navigation source. - Added a language switch (JA / EN) in
Header.astro. - Added canonical and hreflang handling to
Layout.astro. - Switched
<html lang>dynamically based on the URL.