This comprehensive guide covers the scalable multi-language system implemented for this Jekyll blog, supporting unlimited languages with centralized configuration and professional UI components.
- Quick Start
- System Overview
- Configuration
- Language Detection
- Language Switcher UI Components
- Translation Management
- Implementation Examples
- Migration Guide
- SEO & Performance
- Troubleshooting
- Add to
_config.yml:
languages:
es:
flag: "🇪🇸"
name: "Español"
code: "es"
locale: "es_ES"
url: "/es/"- Create homepage (
es.md) - Create translated pages with
translationsarray - No code changes needed - system automatically includes new language!
---
title: About
lang: en
translations:
- lang: pt
url: "/sobre"
- lang: fr
url: "/a-propos"
- lang: es
url: "/acerca-de"
---_config.yml- Centralized language configuration_includes/language-detection.html- Smart language detection logic- Language Switcher Components - Multiple professional UI variations
- CSS Styling - Responsive, accessible design
- Translation System - Flexible page-to-page translation mapping
- ✅ Unlimited Languages - Add any number of languages through configuration
- ✅ Automatic Detection - Smart language detection from page/post frontmatter
- ✅ Professional UI - Multiple dropdown menu styles available
- ✅ SEO Optimized - Proper
hreflangattributes and language-specific URLs - ✅ Mobile Responsive - Optimized for all screen sizes
- ✅ Backward Compatible - Seamless migration from old two-language system
- ✅ Zero Dependencies - Pure HTML/CSS implementation
# Multi-language configuration
languages:
en:
flag: "🇺🇸"
name: "English"
code: "en"
locale: "en_US"
url: "/en/"
pt:
flag: "🇧🇷"
name: "Português"
code: "pt"
locale: "pt_BR"
url: "/pt/"
fr:
flag: "🇫🇷"
name: "Français"
code: "fr"
locale: "fr_FR"
url: "/fr/"
# Default language
default_language: ptflag- Emoji flag displayed in UIname- Full language name shown in dropdowncode- Short language identifier (used in frontmatter)locale- Full locale code for SEO (hreflangattribute)url- Homepage URL for this language
The system provides sophisticated language detection that:
- Detects from frontmatter - Checks
page.langandpost.lang - Supports multiple formats - Works with
en,en_US,pt_BR, etc. - Falls back gracefully - Uses default language if none specified
- Provides rich data - Sets multiple variables for easy use
{% include language-detection.html %}
<!-- Now available: -->
{{ current_lang }} <!-- Current language code: "en", "pt", "fr" -->
{{ current_lang_config }} <!-- Full language object with all properties -->
{{ available_languages }} <!-- All configured languages -->{% include language-detection.html %}
{% if current_lang == "en" %}
<h1>Welcome</h1>
{% elsif current_lang == "fr" %}
<h1>Bienvenue</h1>
{% else %}
<h1>Bem-vindo</h1>
{% endif %}Features:
- Supports unlimited languages automatically
- Shows current language with checkmark (✓)
- Right-aligned dropdown menu
- SEO-friendly
hreflangattributes - Smart translation URL detection
Usage:
{% include language-detection.html %}
{% include language-switcher-multi.html %}Appearance:
- Button: "🇺🇸 EN ▼"
- Menu: "🇺🇸 English ✓", "🇧🇷 Português", "🇫🇷 Français"
Features:
- Two-language design with checkmark icons
- Bootstrap glyphicon integration
- Divider between current and alternative language
Features:
- Minimal flag-only toggle button
- Space-efficient design
- Good for tight navigation spaces
/* Multi-Language Switcher Styling */
.language-switcher-multi {
.dropdown-toggle {
padding: 15px 12px;
font-weight: 500;
min-width: 60px;
}
.dropdown-menu {
min-width: 140px;
border-radius: 4px;
box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.current-language {
color: #1bacaf;
font-weight: 600;
background-color: #f8f9fa;
}
}Use the translations array in frontmatter for multi-language pages:
---
title: About
lang: en
translations:
- lang: pt
url: "/sobre"
- lang: fr
url: "/a-propos"
- lang: es
url: "/acerca-de"
---The system intelligently finds translation URLs:
- Specific translation in
translationsarray - Language homepage as fallback
The header automatically adapts navigation based on current language:
{% if current_lang == "en" %}
{% assign options = "About,Books,Talks,CV,GitStudyCards" | split: ',' %}
{% elsif current_lang == "fr" %}
{% assign options = "À propos,Livres,Conférences,CV,GitFichas" | split: ',' %}
{% else %}
{% assign options = "Sobre,Livros,Palestras,CV,GitFichas" | split: ',' %}
{% endif %}---
layout: page
title: My Page
lang: en
translations:
- lang: pt
url: "/minha-pagina"
- lang: fr
url: "/ma-page"
---
{% include language-detection.html %}
<h1>
{% if current_lang == "en" %}
Welcome to my page
{% elsif current_lang == "fr" %}
Bienvenue sur ma page
{% else %}
Bem-vindo à minha página
{% endif %}
</h1>
<!-- Language switcher in sidebar -->
{% include language-switcher-multi.html %}---
layout: post
title: "My Blog Post"
lang: en
translations:
- lang: pt
url: "/meu-post"
- lang: fr
url: "/mon-article"
tags:
- english
- technology
---{% include language-detection.html %}
<div class="welcome-message">
{% case current_lang %}
{% when "en" %}
<h2>Recent Articles</h2>
<p>Check out the latest posts</p>
{% when "fr" %}
<h2>Articles récents</h2>
<p>Découvrez les derniers articles</p>
{% else %}
<h2>Artigos recentes</h2>
<p>Confira os posts mais recentes</p>
{% endcase %}
</div>- Update
_config.yml- Add language configuration - Replace old detection logic - Use
{% include language-detection.html %} - Update page frontmatter - Add
translationsarrays - Replace language switcher - Use new multi-language component
- Test thoroughly - Verify all language switching works
- Add language configuration to
_config.yml - Update main language pages (
en.md,pt.md, add new languages) - Replace old
translatedfields withtranslationsarrays - Update all
{% if post.lang == "en" %}conditionals - Replace language switcher components
- Test language switching on all pages
- Verify SEO attributes are correct
- Check mobile responsiveness
- Language detection variables - Use
current_langinstead of manual checks - Translation frontmatter -
translationsarray replacestranslatedfield - Component includes - New language detection include required
- Proper
hreflangattributes on all language links - Language-specific URLs (
/en/,/pt/,/fr/) - Correct locale codes in configuration
- Canonical URL structure for each language
- Minimal overhead - Only loads necessary language data
- Efficient caching - Language configuration cached by Jekyll
- No JavaScript - Pure HTML/CSS implementation
- Fast rendering - Optimized Liquid template logic
<a href="/about" hreflang="en_US">🇺🇸 English</a>
<a href="/a-propos" hreflang="fr_FR">🇫🇷 Français</a>
<a href="/sobre" hreflang="pt_BR">🇧🇷 Português</a>Language not detected properly?
- Check
langfield in page frontmatter - Verify language is configured in
_config.yml - Ensure
language-detection.htmlis included - Restart Jekyll server after config changes
Dropdown not showing all languages?
- Verify
_config.ymlsyntax is correct - Check Jekyll build logs for errors
- Ensure all language configurations are complete
Translations not working?
- Check
translationsarray syntax in frontmatter - Verify target pages exist
- Test fallback to language homepage
Styling issues?
- Check CSS load order
- Verify Bootstrap integration
- Inspect browser dev tools for conflicts
Add this to any page to debug language detection:
{% include language-detection.html %}
<div class="debug-info" style="background: #f0f0f0; padding: 10px; margin: 10px;">
<h4>Language Debug Info:</h4>
<p><strong>Current Language:</strong> {{ current_lang }}</p>
<p><strong>Available Languages:</strong> {{ available_languages | size }}</p>
<p><strong>Current Config:</strong> {{ current_lang_config }}</p>
<p><strong>Page Lang:</strong> {{ page.lang }}</p>
<p><strong>Post Lang:</strong> {{ post.lang }}</p>
</div>Monitor these metrics:
- Page load times across languages
- Language switcher click-through rates
- SEO indexing of different language pages
- Mobile usability scores
- Cookie-based language preference persistence
- Browser language auto-detection
- Automatic translation suggestions
- Language-specific search functionality
- RTL language support (Arabic, Hebrew)
- Regional variants (en-US vs en-GB)
- Language-specific date/number formatting
- Custom language-based theming
This scalable multi-language system provides:
✅ Easy language management through centralized configuration
✅ Professional UI components with multiple style options
✅ Smart detection logic supporting various language formats
✅ SEO optimization with proper attributes and structure
✅ Mobile responsiveness across all devices
✅ Future-proof architecture ready for unlimited languages
The system automatically scales as you add new languages - just update the configuration and create your content pages. No code changes required! 🌍✨