Skip to content

Fix mkdocs serve and Material on multi-language sites - #153

Merged
shenxianpeng merged 4 commits into
mainfrom
claude/project-thread-0swvxa
Nov 2, 2026
Merged

shenxianpeng merged 4 commits into
mainfrom
claude/project-thread-0swvxa

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Two bugs I found while testing the new languages setting (#146) end to end, one commit each. Both are in 1.11.0rc1. The release notes are under 1.11.0 (unreleased).

mkdocs serve answered 404 for every page of the default language. The faster rebuilds from #145 remove the files that the previous build wrote and the current one didn't. Each language is its own build, so building zh removed the English pages (and the next rebuild did the reverse). mkdocs build wasn't affected. The languages of a site now count as one build of the site directory: SiteOutput.start_languages() / end_languages() wrap them, and stale files are removed once every language is built. A page deleted from one language is still removed on the next rebuild.

Material for MkDocs showed every language in English (<html lang="en">, English search box and labels). Material reads theme.language, not theme.locale. With theme.name: material, theme.language is now set like theme.locale: to the language code, unless the language or (for the default language) mkdocs.yml sets it. The Multi-language Sites page says so.

Tests:

  • New tests in output_tests.py (they fail without the fix) and languages_tests.py. The full suite passes.
  • By hand: sumi-starter served with both languages staying at 200 across edits in docs/ and docs-zh/, and a removed page went away.
  • By hand: a Material site with search, blog, tags, macros, redirects, git-revision-date-localized, mkdocstrings, glightbox and minify builds both languages with --strict. The Chinese site has lang=zh and the Chinese UI.

The faster rebuilds of `mkdocs serve` remove the files that the previous
build wrote and this one didn't. Each language counted as a build of its
own, so building Chinese removed the English pages, and the next rebuild
the other way round: the default language answered 404.

The languages of a site now count as one build of the site directory:
stale files are removed once all of them are built.
Material reads its language from `theme.language`, not `theme.locale`, so
every language of a site built with it said `<html lang="en">` and showed
the English interface. `theme.language` is now set the same way as
`theme.locale`: to the language code, unless the language or (for the
default language) mkdocs.yml sets it.
@shenxianpeng shenxianpeng changed the title Keep every language when mkdocs serve rebuilds a multi-language site Fix mkdocs serve and Material on multi-language sites Nov 2, 2026
@github-actions github-actions Bot added the bug Something isn't working label Nov 2, 2026
@codspeed

codspeed Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing claude/project-thread-0swvxa (35f9d5b) with main (f4b3e21)

Open in CodSpeed

…-0swvxa

# Conflicts:
#	docs/about/release-notes.md

shenxianpeng commented Nov 2, 2026 •

Copy link
Copy Markdown
Member Author

The CodSpeed check reports a -17.8% regression in test_get_yaml_loader, which isn't this PR's. That benchmark only times mkdocs.utils.yaml.get_yaml_loader, and this PR doesn't touch mkdocs/utils/yaml.py or anything it calls. CodSpeed flags the result as measured on different hardware than the base. On the previous head of this PR, with the same code, the same benchmark showed +21%. I've re-run the benchmarks once. If it is still red, the swing is runner noise and can be acknowledged on CodSpeed. Every other check is green.

@shenxianpeng
shenxianpeng merged commit 80488fb into main Nov 2, 2026
25 checks passed
@shenxianpeng
shenxianpeng deleted the claude/project-thread-0swvxa branch November 2, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant