This guide explains how to create and manage bilingual content using the automatic translation discovery system.
The multilingual system allows you to:
- Publish content in multiple languages (currently English and Spanish)
- Link related translations via shared IDs
- Hide secondary language versions from main listings
- Display language toggles for easy switching between versions
Use the same translationGroup value in both language versions:
# English version - featured in main listings
---
title: 'My Article'
language: ['en']
featured: true
translationGroup: 'my-unique-article-id'
---
# Spanish version - hidden from main listings
---
title: 'Mi Artículo'
language: ['es']
featured: false
translationGroup: 'my-unique-article-id'
---- Primary language: Set
featured: true(appears in listings) - Secondary language: Set
featured: false(discoverable via language toggle only) - Language array: Use
["en"]for English,["es"]for Spanish
Choose descriptive, unique IDs for translationGroup:
recovery-progress-reporttoddler-internet-safetycooking-fundamentals
When readers view a post with translations, they see:
🌐 Read in other languages:
🇺🇸 English | 🇪🇸 Español
The current language is automatically hidden from the toggle.
- Featured posts (
featured: true) appear in:- Homepage post listings
- Category pages
- Tag pages
- RSS/JSON feeds
- Non-featured posts (
featured: false) are:- Accessible via direct URL
- Discoverable via language toggle
- Hidden from main listings
- Excluded from feeds
- LanguageToggle.astro: Displays available translations
- translationUtils.ts: Core translation discovery logic
- BlogLayout.astro: Integrates language toggle into post layout
The system:
- Finds all posts with matching
translationGroup - Filters out drafts and unpublished posts
- Generates language links with appropriate flags
- Displays toggle only when translations exist
All translation functionality is fully typed with TypeScript:
interface Translation {
id: string;
title: string;
language: string[];
path: string;
}
interface TranslationData {
translations: Translation[];
currentLanguage: string;
currentPath: string;
hasTranslations: boolean;
}- Choose primary language: Usually English for wider reach
- Consistent translation groups: Use descriptive, permanent IDs
- Complete translations: Ensure both versions are substantively equivalent
- Synchronized publishing: Publish translations together when possible
- Each language version has its own URL
- Proper
langattributes are set automatically - Search engines index both versions separately
- No duplicate content issues (different languages)
- Titles: Translate meaningfully, not literally
- Descriptions: Adapt for cultural context
- Tags: Use language-appropriate tags
- Images: Can be shared between versions
- Check
translationGroupvalues match exactly - Verify both posts have
published: true - Ensure neither post has
draft: true - Confirm
languagearrays are correctly set
- Only one version per translation group should have
featured: true - Secondary languages should always use
featured: false
- Translation toggle only appears when 2+ translations exist
- Check that posts share the same
translationGroup - Verify posts are published and not drafts
Planned features:
- Additional language support
- Language-specific RSS feeds
- Automatic translation status indicators
- Content synchronization tools
For issues or questions about multilingual content:
- Check this documentation
- Review example translation pairs in
/src/content/p/ - Submit issues via GitHub