Repository navigation
Build every language of a site from one mkdocs.yml - #146
Merged
Merged
Conversation
A new `languages` setting lists the languages of a site. The first one is built at the root of the site and the others into /<code>/. Each language can override any setting, such as site_name or nav. Translations sit next to the original page as page.zh.md, or in a docs_dir of the language's own. A page that has no translation is built from the default language's version, unless the language sets `fallback: false`. Each language is an ordinary build with its own config and its own plugin instances, so plugins see a normal single-language site. Themes get an `i18n` template variable, and `extra.alternate` is filled in for each page so that the language switcher of Sumi and Material links to the same page in the other languages. `mkdocs build` and `mkdocs serve` take `--language` to work on one language only. Also: - Don't warn about missing gettext catalogs for themes that have none (Sumi, Material): the warning failed --strict builds of non-English sites when Babel is installed. - Fix the `url` filter for paths above the site root that repeat part of the current page's path, such as ../guide/ on the page guide/.
This was referenced Nov 2, 2026
Contributor
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multi-language sites today need one config file per language (
mkdocs.zh.ymlwithINHERIT, its owndocs_dir/site_dir, a hand-writtenextra.alternate) and onemkdocs buildper language. This adds native support: onemkdocs.ymldeclares every language.guide.zh.md, or in a language's owndocs_dir(e.g.docs-zh). Links andnavuse the plain names in every language. Any file can be translated (img/shot.zh.png).fallback: falseleaves them out instead. Images are always shared.theme.locale= language code,site_urlandsite_dirget/<code>/added (path:changes the directory).extra.alternateis filled in per page (unless the config sets it), linking to the same page in each language, so Sumi and Material show it without setup. Themes also get a newi18ntemplate variable (current language,fallbackflag, per-languagelink/url/available) for menus andhreflangtags.mkdocs buildbuilds all languages,mkdocs serveserves and watches all of them; both take--language/-Lto work on one.Plugin compatibility: each language is an ordinary build with its own config, loaded from the same file with that language's overrides, and its own plugin instances. Plugins see a normal single-language site. (Plugins with
on_startupare shared across languages, as they are acrossserverebuilds.) Unlike mkdocs-static-i18n, nothing reconfigures other plugins. Sites withoutlanguagestake exactly the old code path.Two fixes found along the way:
theme.localewhen Babel is installed. It failed--strictbuilds of every non-English site.urlfilter returned the current page for a path above the site root that repeats the page's path (../guide/onguide/). Now it returns../../../guide/.Tested with the built-in themes, Sumi and Material, and with sumi-starter converted to a single config (strict build passes,
servepreviews both languages).Related Issue
Roadmap #59 (i18n was planned for 2.x; done now).
Checklist
languagesin the configuration reference,i18nin the theme guidedocs/about/release-notes.mdupdated (if applicable)