How to Set Up Internationalization (i18n) for a Static Site

Supporting multiple languages on a static site requires deliberate structure decisions for content, routing, and SEO. This guide covers the core approaches for internationalizing a static site.

Choosing a URL Structure for Multiple Languages

StructureExampleConsideration
Subdirectoryyourdomain.com/fr/Simple, single domain, common choice for static sites
Subdomainfr.yourdomain.comCleaner separation, slightly more DNS/config overhead
Separate domainyourdomain.frStrongest geographic/language signal, most overhead

Subdirectory structure is generally the simplest and most common approach for static sites, requiring no additional DNS configuration.

Structuring Content by Language

content/
  en/
    home.md
    about.md
  fr/
    home.md
    about.md

Most static site generators support language-specific content directories, with build tooling generating the corresponding language-prefixed output paths automatically.

Setting Up hreflang Tags

<link rel="alternate" hreflang="en" href="https://yourdomain.com/en/about" />
<link rel="alternate" hreflang="fr" href="https://yourdomain.com/fr/about" />
<link rel="alternate" hreflang="x-default" href="https://yourdomain.com/en/about" />

Essential for correct SEO handling of multilingual content — tells search engines about equivalent pages in different languages, helping them serve the appropriate language version to users based on their locale.

Handling Language Detection and Redirection

location = / {
    if ($http_accept_language ~* "^fr") {
        return 302 /fr/;
    }
    return 302 /en/;
}

Redirecting based on browser language preference at the root is a common pattern — but always allow users to manually switch languages afterward, since automatic detection isn't always correct (VPN users, multilingual users with unexpected preferences).

Providing a Clear Language Switcher

Ensure every page has an obvious, easily accessible way to switch languages — don't rely solely on automatic detection; users need explicit control over their language preference.

Localizing More Than Just Text

Consider dates, number formats, currency, and even images/examples that might need cultural adaptation, not just translated text strings — genuine localization goes beyond word-for-word translation.

Managing Translation Content

For larger sites, consider a translation management workflow (dedicated translation files, or integration with a translation service/platform) rather than ad-hoc translated content scattered through your codebase — particularly valuable as your site and language count grow.

Handling Untranslated Content Gracefully

Decide your fallback behavior for content not yet translated into a specific language (show in default language with a note, versus hiding entirely) — be deliberate about this rather than having inconsistent, undocumented behavior across different pages.

Common Errors

Search engines indexing the wrong language version for certain queries — verify your hreflang implementation is correct and complete (bidirectional references between all language versions of the same content); incomplete or incorrect hreflang is a common source of this issue.

Continue Reading

Browse more articles in Static Site Hosting & Frontend Deployment.

  • static site internationalization, i18n hreflang setup, multilingual static site, static site language switcher
  • 0 أعضاء وجدوا هذه المقالة مفيدة
هل كانت المقالة مفيدة ؟

مقالات مشابهة

How to Host a Static Website on a VPS with Nginx

Static websites — plain HTML, CSS, and JavaScript with no server-side processing —...

How to Deploy a Next.js Application on a VPS

Next.js supports several deployment modes — fully static export, server-side rendering with...

How to Deploy a Static Site Built with Astro, Hugo, or Jekyll

Static site generators (Astro, Hugo, Jekyll) produce plain HTML/CSS/JS at build time —...

How to Optimize Images for Web Performance

Images are typically the largest contributor to page weight and load time. This guide covers...

How to Set Up a Jamstack Site with a Headless CMS Backend

The Jamstack architecture (JavaScript, APIs, Markup) combines a pre-built static frontend with a...