Internationalization

Setting up multi-language sites with locale configuration and RTL support

VitePress supports multi-language sites through locale configuration.

Directory Structure

Organize content by locale:

docs/
├─ en/
│  ├─ guide.md
│  └─ index.md
├─ zh/
│  ├─ guide.md
│  └─ index.md
└─ fr/
   ├─ guide.md
   └─ index.md

Or with root as default language:

docs/
├─ guide.md        # English (root)
├─ index.md
├─ zh/
│  ├─ guide.md
│  └─ index.md
└─ fr/
   ├─ guide.md
   └─ index.md

Configuration

Locale-Specific Config

Override site config per locale:

Locale-Specific Properties

Each locale can override:

Search i18n

Separate Locale Directories

For fully separated locales without root fallback:

Requires server redirect for //en/. Netlify example:

Persisting Language Choice

Set cookie on language change:

RTL Support (Experimental)

For right-to-left languages:

Requires PostCSS plugin like postcss-rtlcss:

Organizing Config

Split config into separate files:

Key Points

  • Use locales object in config with root for default language

  • Each locale can override title, description, and themeConfig

  • themeConfig is shallow merged (define complete nav/sidebar per locale)

  • Don't override themeConfig.algolia at locale level

  • dir: 'rtl' enables RTL with PostCSS plugin

  • Language switcher appears automatically in nav

Last updated

Was this helpful?