Multilingual & Wiki System
This page explains a signature feature of this blog — the multilingual multi-Wiki system: one config manages multiple wiki document sets (docs/api/tutorial), each wiki can have multiple language versions (zh-cn/en), missing translations fall back to the default language automatically, and correct canonical/hreflang tags are output for search engines. This page is also the creation & maintenance manual for wiki pages.
The
preferencesection ofuserConfig/_config.tmp.ymlis the authoritative config source.How to read: every section follows “How to enable → Common options → All tunable keys → Boundaries & conflicts”. See the effect first, then the corresponding config that produces it — copy and use.
1. Feature Overview
Purpose: one directory convention + one sidebar data file is enough to run a multi-wiki, multilingual documentation system.
Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts
1.1 How to enable
Effect: after creating the source/tutorial/ directory and source/_data/tutorial-sidebar.yml, visiting /tutorial/ shows a wiki with a left chapter tree; drop in a source/en/tutorial/ translation and /en/tutorial/ serves the English version — there is no registration step; the directory is the registration.
Corresponding config (theme config, preference section):
preference:
default_lang: zh-cn # default language: used for prefix-less paths
wiki:
enable: true # master switch of the multilingual wiki system1.2 Common options
Capability overview (current implementation boundaries):
| Feature | Description |
|---|---|
| Multi-wiki | auto-scans source/{wiki}/ directories (currently: docs / api / tutorial) |
| Multilingual | 9-language capability table (de/en/eo/es/ja/ru/zh-CN/zh-HK/zh-TW); lang_meta enabled controls activation (currently: zh-cn / en) |
| Path prefix | language versions are distinguished by path prefix: /docs/setup/ (default) vs /en/docs/setup/ (English) |
| Fallback | three-level fallback chain: requested language → fallback_lang → default_lang → any available; the notice bar shows the actual fallback source language |
| Independent sidebar | one source/_data/{wiki}-sidebar.yml sidebar data file per wiki |
| SEO | correct html lang + canonical per page; hreflang output when a translated version exists |
① Enable a second language
Effect: the language appears in the dropdown, and /{lang}/ paths plus fallback pages start being generated.
Corresponding config:
preference:
lang_meta:
en:
name: English
flag: 🇬🇧
enabled: true # only this matters: true takes effect② Specify the middle fallback layer
Effect: when the requested language has no content, this language’s content is used first instead of dropping straight to the default language.
Corresponding config:
preference:
fallback_lang: en # must be enabled in lang_meta1.3 All tunable keys
| Key | Type | Default | Options/Range | Purpose |
|---|---|---|---|---|
preference.default_lang | string | zh-cn | any language in lang_meta | default language (no URL prefix) |
preference.fallback_lang | string | first enabled non-default language | enabled language in lang_meta | middle fallback layer |
preference.lang_meta.<lang>.name | string | — | any string | language dropdown display name |
preference.lang_meta.<lang>.flag | string | — | emoji | language dropdown flag |
preference.lang_meta.<lang>.enabled | bool | false | true / false | whether the language is active |
preference.wiki.enable | bool | true | true / false | multilingual wiki master switch |
preference.translate.enable | bool | true | true / false | Chinese trad/simp conversion button |
1.4 Boundaries & conflicts
- Language capability table = keys of
lang_meta(all 9 languages supported); active languages = keys withenabled: true— inactive languages generate no fallback pages, appear in no language dropdown, and are not fallback targets. - The wiki system auto-scans
source/{wiki}/directories (front-matterlayout: wiki) andsource/_data/{wiki}-sidebar.yml— no config registration needed. - The old
preference.wiki.default_lang/langslocation is deprecated (migrated 2026-09-08;lang-config.jsstill reads it as fallback during the transition).
1.5 Summary
- Minimum viable:
default_lang+wiki.enable - Want multiple languages: set the target language’s
enabled: trueinlang_meta - Want to write fewer translations: rely on
fallback_langinstead of copying pages - New language not working: confirm
enabled: trueand thatname/flagwere added
2. Config Details (preference language section)
Purpose: the
preferencelanguage section is the single entry point for site-wide language behaviour (shared by wiki / post / search).Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts
2.1 How to enable
Effect: with this block written, the site defaults to zh-cn with en as fallback, and only these two appear in the language dropdown.
Corresponding config (theme config, preference section; migrated from preference.wiki to site-wide on 2026-09-08, duplicate langs removed):
preference:
default_lang: zh-cn # default language (used for prefix-less paths; all components: wiki/post/search)
fallback_lang: en # fallback language: used first when the requested language version is missing (must be enabled in lang_meta)
lang_meta: # language capability table + enable switch: key=language, enabled=true only takes effect
zh-cn:
name: 简体中文
flag: 🇨🇳
enabled: true
en:
name: English
flag: 🇬🇧
enabled: true
de:
name: Deutsch
flag: 🇩🇪
enabled: false
# ... all 9 languages (de/en/eo/es/ja/ru/zh-CN/zh-HK/zh-TW), enabled controls activation
wiki:
enable: true # master switch of the multilingual wiki system (wiki-specific switch stays here)
# Chinese trad/simp conversion (formerly footer.translate, consolidated here on 2026-08-16)
translate:
enable: trueLanguage metadata keys explained one by one:
| Key | Purpose |
|---|---|
default_lang | language used for prefix-less paths; also the third layer of the fallback chain |
fallback_lang | second layer of the fallback chain; default = first enabled non-default language |
lang_meta.<code> | language code, must match the directory name (en ↔ /en/) |
lang_meta.<code>.name | dropdown display name; must be added for a new language |
lang_meta.<code>.flag | dropdown flag emoji; must be added for a new language |
lang_meta.<code>.enabled | the only activation switch; false means the language does not exist at all |
wiki.enable | wiki system master switch |
translate.enable | trad/simp conversion switch (default direction see zhDefaultEncoding) |
2.2 Common options
① Change the default language
Effect: the /docs/ prefix switches to that language; other languages then need a prefix.
Corresponding config:
preference:
default_lang: en② Add a language entry
Effect: the new option appears in the language dropdown; without translation files, the fallback chain shows other content instead.
Corresponding config:
preference:
lang_meta:
ja:
name: 日本語
flag: 🇯🇵
enabled: true2.3 All tunable keys
| Key | Type | Default | Options/Range | Purpose |
|---|---|---|---|---|
preference.default_lang | string | zh-cn | any language in lang_meta | default language |
preference.fallback_lang | string | first enabled non-default language | enabled language | middle fallback layer |
preference.lang_meta | map | all 9 languages | language code as key | language capability table |
preference.wiki.enable | bool | true | true / false | wiki system switch |
preference.translate.enable | bool | true | true / false | trad/simp conversion |
zhDefaultEncoding | number | 2 | 1 (traditional) / 2 (simplified) | default trad/simp direction |
2.4 Boundaries & conflicts
default_langis not written into the URL prefix (/docs/is Chinese); other languages are (/en/docs/).fallback_langmust itself be an enabled language, otherwise that layer is skipped.name/flaginlang_metaonly affect display, not generation; if omitted, the dropdown lacks its label.
2.5 Summary
- Minimum viable:
default_lang+ one language withenabled: true - New language trio: code +
name/flag+enabled: true - Don’t touch
default_lang’s prefix path: existing external links break - Trad/simp direction: adjust
zhDefaultEncoding
3. Language Switching (preference panel)
Purpose: readers switch language/trad-simp from the preference panel in the top-right corner.
Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts
3.1 How to enable
Effect: a language dropdown (with flags) and a trad/simp button appear in the preference panel at the top-right; switching jumps to the current page’s version in that language.
Corresponding config:
preference:
translate:
enable: true3.2 Common options
① Language switching
Effect: the panel’s language dropdown lists all languages in lang_meta (with flags); switching jumps to the current page’s version in that language.
Corresponding config: preference.lang_meta (see §2), no separate switch.
② Trad/simp conversion
Effect: a trad/simp button appears in the panel; clicking converts the body between traditional and simplified.
Corresponding config:
preference:
translate:
enable: trueThe default direction is decided by zhDefaultEncoding (1 traditional / 2 simplified).
③ Remembered preference
Effect: the reader’s last choice is remembered and loaded automatically on the next visit.
Corresponding config: none — the choice is stored in localStorage (key wiki_lang).
3.3 All tunable keys
| Key | Type | Default | Options/Range | Purpose |
|---|---|---|---|---|
preference.translate.enable | bool | true | true / false | trad/simp button |
zhDefaultEncoding | number | 2 | 1 / 2 | default trad/simp direction |
preference.lang_meta.<lang>.enabled | bool | false | true / false | whether the language appears in the dropdown |
Client language strategy (2026-09-10, Plan A — site-wide follow):
- First-visit prompt: no saved preference and browser language matches an enabled (non-default) language → a dialog asks whether to switch; accept = remember + jump, decline = remember the default language (never asked again)
- Load / refresh follow: with a saved preference, any page loads directly in that language version (inline redirect in
head, before render — no flash); crawlers are skipped (SEO); paths without a multilingual version are skipped (no 404) - Panel display: the language dropdown shows the saved preference (
localStorage.wiki_lang), not the current URL language
3.4 Boundaries & conflicts
404 / aggregate / encrypted page language (2026-09-27):
- 404 page: switched to client-side language detection (single file) — copy language follows the visitor’s browser language / saved preference instead of statically generating one page per language (the old
/en/404.htmletc. are no longer needed) - archives aggregate page: unified pagination across all languages — no longer diverges per language; every language version shares the same pagination structure
- Encrypted page language: encryption prompt / button copy follows the page language (hbe-bundle fallback copy goes through
MATERY_I18N, E7 2026-09-27) - In-content links & runtime copy: in-content links (
url_for_lang) point to the matching language version; search / dialog runtime copy is i18n-ised too (P0/P1)
3.5 Summary
- Minimum viable: enable one non-default language and the dropdown appears
- Trad/simp button missing: check
translate.enable - Language switches back: the save preference is remembered — expected behaviour
- 404 multilingual: already client-detected, no per-language pages needed
4. Wiki Page Creation Flow
Purpose: create a new wiki (or add pages to an existing one). Using the
tutorialwiki as an example (this document is its product), 4 steps total.Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts
4.1 How to enable
Effect: when done, visiting /tutorial/ enters the wiki; the left sidebar renders the chapter tree from tutorial-sidebar.yml automatically (collapsible), with in-wiki navigation at the top of the page.
Corresponding config: three file steps (directory + front-matter + sidebar).
① Create the page directory (source/{wiki}/):
mkdir -p source/tutorial/config # pages go in subdirectories by chapter② Write the page file (front-matter must contain layout: wiki + wiki: <name>):
---
title: Global Configuration
layout: wiki
wiki: tutorial
---
## Global Configuration
Body content...③ Configure the sidebar (source/_data/{wiki}-sidebar.yml, chapter → page mapping):
getting_started:
overview: index.html
install: install.html
basic_config:
global: global.html
multilingual: multilingual.html④ Done: the wiki system auto-scans the source/tutorial/ directory (front-matter layout: wiki + wiki: tutorial) — no config registration needed.
4.2 Common options
① Add a page to an existing wiki
Effect: the new page appears in the specified sidebar section and its link works.
Corresponding config: source/{wiki}/xxx.md + add a line to the matching section in sidebar.yml (both steps required).
② Add a translated version
Effect: an English page appears at /en/{wiki}/xxx/, reachable from the language dropdown.
Corresponding config: source/en/{wiki}/xxx.md (same front-matter as above, plus lang: en).
4.3 All tunable keys
| Key | Type | Default | Options/Range | Purpose |
|---|---|---|---|---|
front-matter layout | string | — | wiki | declare a wiki page (required) |
front-matter wiki | string | — | wiki name (matching the directory name) | which wiki it belongs to (required) |
front-matter lang | string | preference.default_lang | en etc. | translation language marker |
front-matter toc | bool | inherits global | true / false | per-page TOC switch |
_data/{wiki}-sidebar.yml | map | — | section: page-key: page.html | sidebar structure |
4.4 Boundaries & conflicts
- The path prefix (
/en/...) is decided bypage.lang; a translation page missinglang: enis treated as the default language, so links point to/docs/instead of/en/docs/. - The
wikiname must match the_data/{wiki}-sidebar.ymlfilename, otherwise the sidebar doesn’t render. - The page slug must match the sidebar.yml key, otherwise sidebar links 404.
4.5 Summary
- Minimum viable: one md file (two front-matter keys) + one sidebar.yml
- Page added but sidebar unchanged: forgot to add a line in sidebar.yml
- Sidebar 404: key and filename don’t match
- Translation page shows the wrong language: add
lang: en
5. Sidebar Data Format
Purpose: define the order and hierarchy of the wiki’s left chapter tree.
Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts
5.1 How to enable
Effect: the sidebar renders a two-level “section → page” tree in YAML order, collapsible.
Corresponding config (source/_data/{wiki}-sidebar.yml):
# tutorial-sidebar.yml example
guides:
layout: layout.html
tag-plugins: tag-plugins.html
basic_config:
global: global.html
nav-home: nav-home.html
post: post.html
widgets: widgets.html
advanced_config:
code-highlight: code-highlight.html
multilingual: multilingual.htmlFormat: section name: page-key: page.html — the key is the page file’s slug, the value is the HTML path relative to that wiki’s root.
5.2 Common options
① Adjust the order
Effect: sections/pages change position in the sidebar.
Corresponding config: change the key order in the YAML (section order = render order; page order within a section = file order).
② Point to a page in a subdirectory
Effect: the sidebar link points to the page generated from source/tutorial/guide/xxx.md.
Corresponding config:
guides:
tag-plugins: guide/tag-plugins.html5.3 All tunable keys
| Key | Type | Default | Options/Range | Purpose |
|---|---|---|---|---|
| top-level key (section name) | string | — | any string | sidebar group title |
| second-level key (page key) | string | — | md file slug | page identifier |
| second-level value (path) | string | — | .html path relative to the wiki root | page link |
5.4 Boundaries & conflicts
- Sidebar values must point to real file paths (e.g.
guide/tag-plugins.html↔source/tutorial/guide/tag-plugins.md), otherwise sidebar links 404. - Adding a page = ① create the md file ② add a line to the corresponding section in sidebar.yml — both steps required.
5.5 Summary
- Minimum viable: one section + one page
- Sidebar order wrong: change the YAML line order
- Link 404: path doesn’t match the real file
- Don’t duplicate keys: a same-named key is overwritten
6. Multilingual & Translation
Purpose: agree where translation files live and how front-matter marks them, so the system links them automatically.
Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts
6.1 How to enable
Effect: once a same-named file exists under source/{lang}/ for the same path, that language’s URL has real content and no longer serves a fallback page.
Corresponding config (directory convention):
source/
├── docs/ # default language (zh-cn): docs wiki Chinese pages
│ ├── index.md
│ ├── setup.md
│ └── …
├── en/
│ ├── docs/ # docs wiki English translations
│ │ ├── index.md
│ │ ├── setup.md
│ │ └── …
│ ├── api/
│ └── tutorial/
└── _data/
├── docs-sidebar.yml
└── tutorial-sidebar.yml6.2 Common options
① Wiki page translation
Effect: /en/docs/setup/ shows English content, and sidebar links carry the /en prefix.
Corresponding config (English page front-matter):
layout: wiki
wiki: docs
lang: en② Post translation
Effect: /en/posts/{abbrlink}/ serves the English post, linked to the Chinese version.
Corresponding config (source/en/_posts/{same name as Chinese}.md):
abbrlink: "same value"
lang: enTranslation essentials:
- English pages also write
layout: wiki+wiki: docsin front-matter, and addlang: en— the sidebar link prefix depends onpage.lang(wiki_sidebarusespage.lang || default_lang); if omitted the page is treated as the default language and links point to/docs/instead of/en/docs/ - The language codes in
lang_metamatch the directory names (en↔/en/) - The sidebar data is maintained once for the default language only; translations reuse it
Post translation (source/{lang}/_posts/): same “same filename” convention as wiki —
| Type | Translation source | front-matter |
|---|---|---|
| Post | source/{lang}/_posts/{same name as Chinese}.md | keep the same abbrlink + lang: en |
- Chinese/English linking has two modes: with the abbrlink plugin → matched by identical abbrlink; without it → matched by identical filename (with a filesystem fallback check)
- Hexo natively only recognizes
source/_posts/(en/_posts/is ignored); post translations are generated by the theme’si18n-post-generator.jsat/{lang}/posts/{abbrlink}/ - A real translation → a real content page; otherwise → a fallback page (see §7)
6.3 All tunable keys
| Key | Type | Default | Options/Range | Purpose |
|---|---|---|---|---|
front-matter lang | string | preference.default_lang | enabled languages such as en | marks the page’s translation language |
front-matter abbrlink | string | generated by the plugin | same as the original | Chinese/English post linking key |
directory source/{lang}/{wiki}/ | path | — | same name and path as the source file | translation file location |
directory source/{lang}/_posts/ | path | — | same name as the Chinese file | post translation location |
6.4 Boundaries & conflicts
abbrlinkmust match the Chinese original, otherwise the two language versions cannot be linked. The abbrlink is generated by thehexo-abbrlinkplugin on first build and written into front-matter (withwriteback: falseit is no longer written back, so the field is fixed) — never manually edit the abbrlink of an existing post.- Translation file paths must have the same name and path as the source file; renaming breaks the link.
- Translating only some pages is allowed — missing ones go through the fallback chain.
6.5 Summary
- Minimum viable: same directory name +
langmarker - Posts not linking: check whether
abbrlinkmatches - Sidebar links point to Chinese: translation page is missing
lang: en - Sidebar needs no translation: maintain the default language only
7. Fallback Mechanism (unified as a three-level chain on 2026-09-08)
Purpose: when a page has no translation in a language, visiting that language path still returns content instead of a blank page.
Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts
7.1 How to enable
Effect: visiting /de/docs/setup/ returns fallback content even if de has no translation, with a notice bar at the top: “de language not found, showing xx language version”.
Corresponding config:
preference:
default_lang: zh-cn
fallback_lang: en
lang_meta:
de:
enabled: true # only an enabled de gets fallback pages generatedFallback chain (unified across all modules: wiki/post/archive-pages/search, resolved by lang-config.js):
requested language exists? → use it
→ not found → fallback_lang exists? → fall back to fallback_lang
→ not found → default_lang exists? → fall back to default_lang
→ not found → any available language (first one)7.2 Common options
① Shorten the fallback path
Effect: set fallback_lang to the default language and the middle layer coincides with the third, dropping straight to the default language.
Corresponding config:
preference:
fallback_lang: zh-cn② Disable a language (no more fallback pages)
Effect: that language’s path returns 404 instead of showing another language’s content.
Corresponding config:
preference:
lang_meta:
de:
enabled: falseFlow (generation-level fallback, generated by scripts/generators/{post,wiki}-fallback.js):
visit /de/docs/setup/ (de enabled but untranslated)
→ en translation exists → fallback page content in en (fallback_lang takes effect) + notice "de not found, showing en"
→ no en translation → fallback page content in zh-cn + notice "de not found, showing zh-cn"7.3 All tunable keys
| Key | Type | Default | Options/Range | Purpose |
|---|---|---|---|---|
preference.default_lang | string | zh-cn | enabled language | third layer of the fallback chain |
preference.fallback_lang | string | first enabled non-default language | enabled language | second layer of the fallback chain |
preference.lang_meta.<lang>.enabled | bool | false | true / false | whether fallback pages are generated for that language |
How fallback pages actually behave:
- Content language is chosen by the fallback chain (
_fallbackFrommarks the actual language); the notice bar shows “xx language not found, showing yy language version” - canonical points to the default language, preventing search engines from indexing duplicate content
- Standalone pages (about/musics/movies/bb/friends/galleries etc.) do generate multilingual versions (
/{lang}/{page}/) — UI copy goes through i18n keys (languages/*.yml), content stays in the author’s language; generated bystandalone-page-generator.jsvia an exclusion rule (layout ∉ {wiki, tags, categories, 404}). Navigation links (url_for_lang) add a language prefix to content paths, pointing to the matching language version - Archive pages (tag/category/archive) generate enabled-language versions (generated only, no notice bar)
7.4 Boundaries & conflicts
- If
fallback_langis not in the enabled list, that layer is skipped and the chain goes straight todefault_lang. - The notice bar only appears on fallback pages; real translation pages have no notice bar.
- Fallback-page canonical points to the default language — don’t change it to the current URL manually.
7.5 Summary
- Minimum viable:
default_lang+fallback_lang - Two levels are enough: set
fallback_langtodefault_lang - Don’t want a language generated:
enabled: false - Notice bar shows the wrong language: check which layer the fallback chain actually hit
8. SEO (canonical / hreflang)
Purpose: let search engines correctly distinguish multilingual versions of the same content, avoiding duplicate indexing.
Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts
8.1 How to enable
Effect: <html lang> matches the language; hreflang tags cross-reference when translations exist; fallback pages point canonical at the default language.
Corresponding config: no extra config — derived automatically from the preference language section + the page’s lang.
8.2 Common options
Output rules (auto-generated per wiki page):
| Scenario | html lang | canonical | hreflang |
|---|---|---|---|
| Default-language page (has translation) | zh-CN | /docs/setup/ | itself + /en/docs/setup/ |
| Translated page | en | /en/docs/setup/ | itself + /docs/setup/ |
| Fallback page (no translation) | zh-CN | /docs/setup/ (points to default) | none |
① Confirm the canonical switch
Effect: when disabled, no canonical tag is output (not recommended).
Corresponding config:
canonical:
enable: true8.3 All tunable keys
| Key | Type | Default | Options/Range | Purpose |
|---|---|---|---|---|
canonical.enable | bool | true | true / false | whether to output canonical |
preference.default_lang | string | zh-cn | enabled language | canonical target language |
front-matter lang | string | default language | enabled language | decides html lang and hreflang |
8.4 Boundaries & conflicts
- Path prefix (not query string) + hreflang + canonical is the standard Google multilingual SEO practice; the sitemap is output uniformly by
hexo-generator-sitemap, wiki pages included automatically. - Fallback pages output no hreflang — they have no independent content, avoiding duplicate-content penalties.
- The root
_config.ymlmust configureurl, otherwise canonical is empty.
8.5 Summary
- Defaults are correct: no need to hand-write hreflang
- canonical empty: check
urlin the root_config.yml - Translation page lang wrong: check front-matter
lang - Don’t add hreflang to fallback pages: it causes duplicate indexing
9. Common Operations
Add a Wiki
- Create the
source/{new-wiki}/directory and pages (front-matter:layout: wiki+wiki: {new-wiki}) - Write the
source/_data/{new-wiki}-sidebar.ymlsidebar - Done — the wiki system auto-scans, no config registration needed
Add a Language
- Add the language code +
name/flag/enabled: truetopreference.lang_meta(enable directly within the 9-language capability table) - Optional: set
preference.fallback_langto that language (as the middle fallback layer) - Create
source/{lang}/{wiki}/for translation files
Add a Post (existing wiki)
- Write
source/tutorial/xxx.md(front-matter as above) - Add a line to the corresponding section of
_data/tutorial-sidebar.yml - Optional: translate to
source/en/tutorial/xxx.md
Add a Post Translation
- Create a file with the same name under
source/en/_posts/(e.g.source/en/_posts/my-post.md) - In front-matter, keep the same abbrlink and add
lang: en - Translate the body to English
- After build, the page is automatically generated at
/en/posts/{abbrlink}/
Key: the abbrlink must match the Chinese original, otherwise the two language versions cannot be linked. The abbrlink is generated by the
hexo-abbrlinkplugin on first build and written into front-matter (withwriteback: falseit is no longer written back, the field is fixed) — never manually edit the abbrlink of an existing post.
Common Troubleshooting
- Sidebar link 404: sidebar.yml key and md filename don’t match
- Sidebar not showing: front-matter missing
layout: wiki, or thewikiname doesn’t match thesource/_data/{wiki}-sidebar.ymlfilename - Config changes not taking effect:
rm -f db.json && hexo generate(see the development notes)
10. Wiki-Wide Encryption Configuration
Purpose: encrypt the entire wiki’s content column and right-side TOC; the left navigation stays visible (navigation is equivalent to a title, and its exposure is acceptable).
Learning path: How to enable → Common options → All tunable keys → Boundaries & conflicts
10.1 How to enable
Effect: on any page of that wiki, the body and right-side TOC are masked and ask for a password, while the left navigation stays visible.
Corresponding config (top-level key in source/_data/{wiki}-sidebar.yml):
encrypt_password: "{{PASSWORD}}"Declaration location: top-level keys in source/_data/{wiki}-sidebar.yml — side by side with navigation section keys like getting_started. The encrypt_ prefix was unified on 2026-09-07 to distinguish them.
10.2 Common options
① Change the prompt copy
Effect: the prompt above the password box changes.
Corresponding config:
encrypt_message: "该栏目已加密,请输入密码"② Change the error message
Effect: custom copy is shown when the password is wrong.
Corresponding config:
encrypt_wpm: "密码不对,请重试"③ Change the input and button copy
Effect: the input placeholder and the decrypt button text change.
Corresponding config:
encrypt_placeholder: "请输入密码"
encrypt_button_text: "解锁"10.3 All tunable keys
| Key | Type | Default | Options/Range | Purpose |
|---|---|---|---|---|
encrypt_password | string | — | plaintext password | the key’s presence enables wiki-wide encryption (required) |
encrypt_message | string | theme encrypt.message | any string | encryption prompt |
encrypt_wpm | string | theme encrypt.wrong_pass_message | any string | wrong-password message |
encrypt_placeholder | string | — | any string | password input placeholder |
encrypt_button_text | string | — | any string | decrypt button label |
The password in the sidebar data uses a
{{PASSWORD}}placeholder. The real value must not be committed to the repository.
10.4 Boundaries & conflicts
Behavior (based on themes/matery/layout/wiki.ejs and themes/matery/source/js/wiki.js):
- Encryption scope: content column only (
encryptHtml(page.content, …)) and right-side TOC (#wiki-toc-asidegets thewiki-toc-encryptedclass); the leftwiki-sidebarnavigation always renders and stays visible - Encryption parameters:
stableSalt: true+storageKey: 'wiki.' + page.wiki— all pages in the same wiki share a single localStorage cache key - TOC rebuild after decryption: a successful frontend decryption triggers the
hexo-blog-decryptevent →wiki.jsremoves thewiki-toc-encryptedclass, changes the content column froml10tol8, then runstocbot.destroy()followed bytocbot.init()— in the encrypted state, body headings are unreadable, so the TOC must be rebuilt after decryption
10.5 Summary
- Minimum viable: one top-level
encrypt_passwordline in sidebar.yml - Only want to change copy: add
encrypt_message/encrypt_wpm - Navigation still leaks: that’s a deliberate trade-off — nav titles are not encrypted
- TOC garbled after decryption: rely on the
hexo-blog-decryptevent to rebuild; don’t build your own TOC
Appendix: Multilingual & Wiki Quick Reference
| Config/file | Description |
|---|---|
preference.enable (inherited from preference.wiki.enable) | system master switch |
preference.default_lang | default language (prefix-less paths) |
preference.fallback_lang | middle fallback language (used first when the requested language is missing) |
preference.lang_meta | language capability table + enabled switch (9 languages) + name/flag |
preference.translate | Chinese trad/simp conversion switch |
source/_data/{wiki}-sidebar.yml | sidebar section → page mapping |
source/{lang}/{wiki}/ | wiki pages per language |
| Fallback | three-level chain: requested → fallback_lang → default_lang → any available; the notice bar shows the actual fallback source language |
| Wiki-wide encryption | top-level encrypt_password in {wiki}-sidebar.yml (other encrypt_* keys optional) |
| SEO | html lang / canonical / hreflang / sitemap output automatically |