Skip to main content

Internationalization

VitePress has built-in support for creating multilingual documentation sites with locale-specific configuration and content.

Directory Structure

Organize content by language using locale-based directories:
  • Root is the default locale (e.g., English)
  • Subdirectories for other languages

Basic Configuration

Configure locales in your VitePress config:
The lang attribute is added to the <html> tag for proper language detection by browsers and screen readers.

Locale-Specific Configuration

Override site configuration per locale:
1

Title and Description

2

Theme Configuration

3

Custom Head Tags

Configurable Properties

These properties can be overridden per locale:
  • lang: HTML language attribute (e.g., 'en', 'es', 'zh-CN')
  • dir: Text direction ('ltr' or 'rtl')
  • title: Site title for this locale
  • titleTemplate: Title format template
  • description: Meta description
  • head: Additional head tags (merged with global head)
  • themeConfig: Theme configuration (shallow merged with global config)
Don’t override themeConfig.algolia or themeConfig.carbonAds at the locale level. See Algolia i18n docs for search localization.

Separate Directory Setup

When using separate directories for all locales, configure server redirects.

Netlify Example

Create docs/public/_redirects:
Persist language choice with a cookie:
This works with Netlify’s Language-based redirects using the nf_lang cookie.

Default Theme Localization

The default theme includes built-in text labels that can be localized:
See the VitePress docs configuration for real examples: docs/.vitepress/config.ts in the source repository.

RTL (Right-to-Left) Support

For RTL languages like Arabic or Hebrew:
1

Set Direction

2

Install PostCSS Plugin

Choose an RTL CSS plugin:
3

Configure PostCSS

RTL support is experimental. Test thoroughly and use :where() selectors to prevent CSS specificity issues.

Organizing Multi-Locale Config

For better organization, split configuration by locale:

Translation Workflow

1

Create Source Content

Write your content in the default language:
2

Duplicate Structure

Create the same structure for each locale:
3

Translate Content

Translate the content while preserving:
  • File names (or update links accordingly)
  • Frontmatter structure
  • Internal link paths (add locale prefix)
4

Update Configuration

Add locale-specific navigation and sidebar

Best Practices

Keep the same file structure across all locales for easier maintenance:
For dynamic content, consider using a translation key system:
Ensure all locales build successfully:
Check for:
  • Broken internal links
  • Missing translations
  • Layout issues with longer text
  • RTL rendering (if applicable)

Language Selector

The default theme automatically adds a language selector to the navigation when multiple locales are configured.

Customizing the Selector

Control the selector appearance:

Accessing Current Locale

In Vue components, access the current locale:

SEO Considerations

1

hreflang Tags

Add alternate language tags:
2

Canonical URLs

Set canonical URLs to avoid duplicate content:
3

Sitemap

Generate locale-aware sitemaps:
See the official VitePress site configuration for a production example: docs/.vitepress/config.ts