Loading...

Loading...

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 preference section of userConfig/_config.tmp.yml is 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 system

1.2 Common options

Capability overview (current implementation boundaries):

FeatureDescription
Multi-wikiauto-scans source/{wiki}/ directories (currently: docs / api / tutorial)
Multilingual9-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 prefixlanguage versions are distinguished by path prefix: /docs/setup/ (default) vs /en/docs/setup/ (English)
Fallbackthree-level fallback chain: requested language → fallback_lang → default_lang → any available; the notice bar shows the actual fallback source language
Independent sidebarone source/_data/{wiki}-sidebar.yml sidebar data file per wiki
SEOcorrect 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_meta

1.3 All tunable keys

KeyTypeDefaultOptions/RangePurpose
preference.default_langstringzh-cnany language in lang_metadefault language (no URL prefix)
preference.fallback_langstringfirst enabled non-default languageenabled language in lang_metamiddle fallback layer
preference.lang_meta.<lang>.namestring—any stringlanguage dropdown display name
preference.lang_meta.<lang>.flagstring—emojilanguage dropdown flag
preference.lang_meta.<lang>.enabledboolfalsetrue / falsewhether the language is active
preference.wiki.enablebooltruetrue / falsemultilingual wiki master switch
preference.translate.enablebooltruetrue / falseChinese trad/simp conversion button

1.4 Boundaries & conflicts

  • Language capability table = keys of lang_meta (all 9 languages supported); active languages = keys with enabled: 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-matter layout: wiki) and source/_data/{wiki}-sidebar.yml — no config registration needed.
  • The old preference.wiki.default_lang/langs location is deprecated (migrated 2026-09-08; lang-config.js still 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: true in lang_meta
  • Want to write fewer translations: rely on fallback_lang instead of copying pages
  • New language not working: confirm enabled: true and that name/flag were added

2. Config Details (preference language section)

Purpose: the preference language 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: true

Language metadata keys explained one by one:

KeyPurpose
default_langlanguage used for prefix-less paths; also the third layer of the fallback chain
fallback_langsecond 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>.namedropdown display name; must be added for a new language
lang_meta.<code>.flagdropdown flag emoji; must be added for a new language
lang_meta.<code>.enabledthe only activation switch; false means the language does not exist at all
wiki.enablewiki system master switch
translate.enabletrad/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: true

2.3 All tunable keys

KeyTypeDefaultOptions/RangePurpose
preference.default_langstringzh-cnany language in lang_metadefault language
preference.fallback_langstringfirst enabled non-default languageenabled languagemiddle fallback layer
preference.lang_metamapall 9 languageslanguage code as keylanguage capability table
preference.wiki.enablebooltruetrue / falsewiki system switch
preference.translate.enablebooltruetrue / falsetrad/simp conversion
zhDefaultEncodingnumber21 (traditional) / 2 (simplified)default trad/simp direction

2.4 Boundaries & conflicts

  • default_lang is not written into the URL prefix (/docs/ is Chinese); other languages are (/en/docs/).
  • fallback_lang must itself be an enabled language, otherwise that layer is skipped.
  • name/flag in lang_meta only affect display, not generation; if omitted, the dropdown lacks its label.

2.5 Summary

  • Minimum viable: default_lang + one language with enabled: 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: true

3.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: true

The 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

KeyTypeDefaultOptions/RangePurpose
preference.translate.enablebooltruetrue / falsetrad/simp button
zhDefaultEncodingnumber21 / 2default trad/simp direction
preference.lang_meta.<lang>.enabledboolfalsetrue / falsewhether 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.html etc. 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 tutorial wiki 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

KeyTypeDefaultOptions/RangePurpose
front-matter layoutstring—wikideclare a wiki page (required)
front-matter wikistring—wiki name (matching the directory name)which wiki it belongs to (required)
front-matter langstringpreference.default_langen etc.translation language marker
front-matter tocboolinherits globaltrue / falseper-page TOC switch
_data/{wiki}-sidebar.ymlmap—section: page-key: page.htmlsidebar structure

4.4 Boundaries & conflicts

  • The path prefix (/en/...) is decided by page.lang; a translation page missing lang: en is treated as the default language, so links point to /docs/ instead of /en/docs/.
  • The wiki name must match the _data/{wiki}-sidebar.yml filename, 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.html

Format: 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.html

5.3 All tunable keys

KeyTypeDefaultOptions/RangePurpose
top-level key (section name)string—any stringsidebar group title
second-level key (page key)string—md file slugpage identifier
second-level value (path)string—.html path relative to the wiki rootpage 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.yml

6.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: en

Translation essentials:

  • English pages also write layout: wiki + wiki: docs in front-matter, and add lang: en — the sidebar link prefix depends on page.lang (wiki_sidebar uses page.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_meta match 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 —

TypeTranslation sourcefront-matter
Postsource/{lang}/_posts/{same name as Chinese}.mdkeep 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’s i18n-post-generator.js at /{lang}/posts/{abbrlink}/
  • A real translation → a real content page; otherwise → a fallback page (see §7)

6.3 All tunable keys

KeyTypeDefaultOptions/RangePurpose
front-matter langstringpreference.default_langenabled languages such as enmarks the page’s translation language
front-matter abbrlinkstringgenerated by the pluginsame as the originalChinese/English post linking key
directory source/{lang}/{wiki}/path—same name and path as the source filetranslation file location
directory source/{lang}/_posts/path—same name as the Chinese filepost translation location

6.4 Boundaries & conflicts

  • abbrlink must match the Chinese original, otherwise the two language versions cannot be linked. The abbrlink is generated by the hexo-abbrlink plugin on first build and written into front-matter (with writeback: false it 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 + lang marker
  • Posts not linking: check whether abbrlink matches
  • 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 generated

Fallback 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: false

Flow (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

KeyTypeDefaultOptions/RangePurpose
preference.default_langstringzh-cnenabled languagethird layer of the fallback chain
preference.fallback_langstringfirst enabled non-default languageenabled languagesecond layer of the fallback chain
preference.lang_meta.<lang>.enabledboolfalsetrue / falsewhether fallback pages are generated for that language

How fallback pages actually behave:

  • Content language is chosen by the fallback chain (_fallbackFrom marks 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 by standalone-page-generator.js via 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_lang is not in the enabled list, that layer is skipped and the chain goes straight to default_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_lang to default_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):

Scenariohtml langcanonicalhreflang
Default-language page (has translation)zh-CN/docs/setup/itself + /en/docs/setup/
Translated pageen/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: true

8.3 All tunable keys

KeyTypeDefaultOptions/RangePurpose
canonical.enablebooltruetrue / falsewhether to output canonical
preference.default_langstringzh-cnenabled languagecanonical target language
front-matter langstringdefault languageenabled languagedecides 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.yml must configure url, otherwise canonical is empty.

8.5 Summary

  • Defaults are correct: no need to hand-write hreflang
  • canonical empty: check url in 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

  1. Create the source/{new-wiki}/ directory and pages (front-matter: layout: wiki + wiki: {new-wiki})
  2. Write the source/_data/{new-wiki}-sidebar.yml sidebar
  3. Done — the wiki system auto-scans, no config registration needed

Add a Language

  1. Add the language code + name/flag/enabled: true to preference.lang_meta (enable directly within the 9-language capability table)
  2. Optional: set preference.fallback_lang to that language (as the middle fallback layer)
  3. Create source/{lang}/{wiki}/ for translation files

Add a Post (existing wiki)

  1. Write source/tutorial/xxx.md (front-matter as above)
  2. Add a line to the corresponding section of _data/tutorial-sidebar.yml
  3. Optional: translate to source/en/tutorial/xxx.md

Add a Post Translation

  1. Create a file with the same name under source/en/_posts/ (e.g. source/en/_posts/my-post.md)
  2. In front-matter, keep the same abbrlink and add lang: en
  3. Translate the body to English
  4. 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-abbrlink plugin on first build and written into front-matter (with writeback: false it 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 the wiki name doesn’t match the source/_data/{wiki}-sidebar.yml filename
  • 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

KeyTypeDefaultOptions/RangePurpose
encrypt_passwordstring—plaintext passwordthe key’s presence enables wiki-wide encryption (required)
encrypt_messagestringtheme encrypt.messageany stringencryption prompt
encrypt_wpmstringtheme encrypt.wrong_pass_messageany stringwrong-password message
encrypt_placeholderstring—any stringpassword input placeholder
encrypt_button_textstring—any stringdecrypt 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-aside gets the wiki-toc-encrypted class); the left wiki-sidebar navigation 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-decrypt event → wiki.js removes the wiki-toc-encrypted class, changes the content column from l10 to l8, then runs tocbot.destroy() followed by tocbot.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_password line 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-decrypt event to rebuild; don’t build your own TOC

Appendix: Multilingual & Wiki Quick Reference

Config/fileDescription
preference.enable (inherited from preference.wiki.enable)system master switch
preference.default_langdefault language (prefix-less paths)
preference.fallback_langmiddle fallback language (used first when the requested language is missing)
preference.lang_metalanguage capability table + enabled switch (9 languages) + name/flag
preference.translateChinese trad/simp conversion switch
source/_data/{wiki}-sidebar.ymlsidebar section → page mapping
source/{lang}/{wiki}/wiki pages per language
Fallbackthree-level chain: requested → fallback_lang → default_lang → any available; the notice bar shows the actual fallback source language
Wiki-wide encryptiontop-level encrypt_password in {wiki}-sidebar.yml (other encrypt_* keys optional)
SEOhtml lang / canonical / hreflang / sitemap output automatically
Comments
Data Loading...