Keywords: astro
• i18n
• internationalization
• multilingual
• url localization
• seo
• typescript
• tailwind css
• static site generation
Multilingual Astro starter with URL localization support. Complete documentation available at the demo link.
Since Astro doesn't have built-in URL localization out of the box, this starter demonstrates how to implement a complete i18n solution for multilingual projects.
Tip
Looking for a more advanced setup? Check the helper‑based branch (slightly more complex):
- Dynamic default language
- Optional language prefix Link: https://github.com/Scorpio3310/astro-i18n-starter/tree/feat/i18n-routing-helper
This project implements a comprehensive internationalization (i18n) system that includes:
✅ SEO-friendly URLs in multiple languages (/about
→ /sl/o-projektu
)
✅ Static generation at build time with dynamic routing
✅ Language-specific content loading and management
✅ Translation system integration with namespace support
✅ Smart language switching with context preservation
✅ Blog system with multilingual posts and pagination
✅ Component examples with Svelte 5 integration
✅ Accessibility features with proper ARIA attributes
✅ SEO optimization with meta tags and keywords
Perfect for: Projects requiring complete URL localization alongside content translation
- Framework: Astro 5.13 - Static site generator
- Components: Svelte 5 - Interactive components with runes
- Styling: Tailwind CSS - Utility-first CSS
- Content: Astro Content Collections - Type-safe markdown content
- Images: Astro Assets - Optimized image processing
# Clone the repository
git clone https://github.com/Scorpio3310/astro-i18n-starter.git
cd astro-i18n-starter
# Install dependencies
pnpm install
# Copy environment file
cp .env.example .env
# Edit .env with your production domain
PRODUCTION_DOMAIN = "https://your-domain.com"
# Start development server
pnpm run dev
Visit http://localhost:4321
to see your multilingual site!
/
├── public/ # Static assets
├── src/
│ ├── assets/ # Assets
│ ├── components/ # Reusable components
│ ├── content/ # Content collections (blog, authors)
│ ├── data/ # Navigation and configuration
│ ├── i18n/ # Translation utilities and routes
│ ├── layouts/ # Page layouts
│ ├── locales/ # Translation files (en, sl)
│ ├── pages/ # File-based routing with [dynamic] params
│ ├── styles/ # Global styles
│ └── utils/ # Utility functions
The system uses dynamic routing with file-based structure:
English: /about → src/pages/[about]/[...index].astro
Slovenian: /sl/o-projektu → src/pages/[about]/[...index].astro
Route Configuration:
// src/i18n/routes.ts
export const routes = {
en: { about: "about", blog: "blog" },
sl: { about: "o-projektu", blog: "spletni-dnevnik" },
};
Dynamic Path Generation:
export function getStaticPaths() {
return [
{ params: { about: "about" }, props: { lang: "en" } },
{ params: { about: "/sl/o-projektu" }, props: { lang: "sl" } }
];
}
- Create page file:
src/pages/[your-route]/[...index].astro
- Add route translations: Update
src/i18n/routes.ts
- Add translations: Create files in
src/locales/en/
andsrc/locales/sl/
- Update navigation: Modify
src/data/navigationData.ts
Detailed documentation with examples is available in the demo site.
# .env
PRODUCTION_DOMAIN = "https://your-domain.com" # Used to enable robots.txt
Important: Set your production domain for proper:
- Open Graph images in social media
- Canonical URLs for SEO
- Search engine indexing control
pnpm run build
pnpm run preview
The site generates static files optimized for any hosting provider (Netlify, Vercel, Cloudflare Pages, etc.).
These items are maintained in the advanced helper‑based branch:
-
Dynamic default language -
Optional language prefix
updates: https://github.com/Scorpio3310/astro-i18n-starter/tree/feat/i18n-routing-helper
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Test locally with
pnpm run build && pnpm run preview
- Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Astro - Amazing static site generator
- Svelte - Excellent component framework
- Tailwind CSS - Great utility CSS framework