Languages (Multi-language Directories)

Methanol supports multi-language sites by treating each directory index page with a lang field as a language entry. This is a lightweight way to organize translations without a separate i18n system.

How It Works

Example structure:

pages/
  index.mdx          # root language
  zh/
    index.mdx        # Chinese language root
    guide.mdx
  fr/
    index.mdx        # French language root
    guide.mdx

Example frontmatter:

---
title: 简体中文
lang: 简体中文
langCode: zh
isRoot: true
hidden: true
---

Language Selector

The default theme shows a language selector when it finds any directory index.mdx pages with lang defined (including the root /). It uses:

A language root often pairs with isRoot: true to scope the navigation tree to that directory.

Note: isRoot pages are hidden by default. Set hidden: false if you want the language root to appear in the sidebar.

This allows separate navigation trees for each language.

What ctx.languages Contains

ctx.languages is an array of language entries collected from directory index pages with lang. Use routeHref for links (it includes site.base).

{
	routePath: '/zh/',
	routeHref: '/zh/',
	label: '简体中文',
	code: 'zh'
}

The root language appears at / when the root index.mdx includes lang.

Tips