Layout & Pages
This page covers the layout & pages features of the matery theme: post layout features, sidebar widgets, responsive breakpoints, galleries, search, comments, dark mode, encryption, RSS/sitemap and PWA. Each feature lists its config location and how to use it.
Config lives in two places: theme config
themes/matery/_config.yml(layout/appearance/interaction) and site config_config.yml(plugins/generators), marked per item below. Note: in this project the theme config file is overwritten by theuserConfig/_config.tmp.ymltemplate during CI builds — sync your changes to the template (see the Installation chapter).How to read this page: every feature is shown as a pair — Effect → Corresponding config. Look at the real page behavior first, then copy the YAML/Stylus below. Defaults come from
userConfig/_config.tmp.yml(same source asthemes/matery/_config.yml); value sets not present there are marked “other values unverified”.
Layout Core & Components
1. Post Layout Features
Purpose: optional modules around a post page — prev/next, copyright, outdated notice, TOC, ad slots. They decide “where to go after finishing a post” and “whether this post is still safe to cite”.
Learning path: How to enable → Common options (per-post overrides) → All tunable keys → Boundaries & conflicts
1.1 How to enable
Prev/next navigation
Effect: two cards at the end of the post showing the adjacent posts’ titles and thumbnails, with a gradient background on hover.
Corresponding config (theme config, inside the post block):
post:
prev_next:
enable: trueCopyright notice
Effect: a grey copyright card at the bottom of the post with author, link and license rows.
Corresponding config (theme config, inside the post block):
post:
copyright:
enable: true # show copyright notice
license: 'cc_by_nc_sa' # default reprint rule (CC BY-NC-SA 4.0)Outdated content notice
Effect: an outdated notice note at the top of the post, more prominent the older the post (warning color first, then error color).
Corresponding config (theme config, inside the post block; default enable: false):
post:
outdate:
enable: true # set to true to enable
warning_day: 365 # show warning-style note after 365 days
error_day: 3650 # show error-style note after 3650 daysTOC
Effect: desktop sidebar TOC tree highlights on scroll; collapsed on mobile.
Corresponding config (theme config, top-level toc section):
toc:
enable: true # global switch
headingSelector: "h2,h3,h4,h5,h6" # heading levels included in the TOC
collapseDepth: 0 # collapse depth, 0 = all collapsedAd slots
Effect: colored ad cards below the sidebar TOC, supporting light/dark background pairs.
Corresponding config (theme config, inside the post block; array, add/remove freely):
post:
advertisements:
- id: "ad-1"
text: "Recommended cheap VPS provider"
link: "https://example.com/your-aff-link"
image: "/medias_webp/cover/hexo.webp" # optional: card image
background: "#6670ff"
background_dark: "#3a4399"
colspan: 1 # card column width
enable: true # false hides it1.2 Common options
Effect: one post hides its TOC; other posts are unaffected.
Corresponding config (front-matter):
toc: falseEffect: one post uses its own reprint license; the site default no longer applies to it.
Corresponding config (front-matter):
reprintPolicy: cc_by_nc # this post: Attribution-NonCommercialAvailable rules (9 total): cc_by, cc_by_nd, cc_by_sa, cc_by_nc, cc_by_nc_nd, cc_by_nc_sa, cc0, noreprint, pay.
Effect: temporarily pull one or all ad cards without deleting config.
Corresponding config: to pull a single card, set its enable to false; to pull all site-wide, comment out the whole advertisements block.
1.3 All tunable keys
| Key | Type | Default | Allowed values / range | Effect |
|---|---|---|---|---|
post.prev_next.enable | bool | true | true / false | Prev/next cards at the end of the post |
post.copyright.enable | bool | true | true / false | Copyright card at the end of the post |
post.copyright.license | string | cc_by_nc_sa | one of the 9 rules above | Default reprint rule |
post.outdate.enable | bool | false | true / false | Master switch for the outdated notice |
post.outdate.warning_day | int | 365 | days | Use warning style after this many days |
post.outdate.error_day | int | 3650 | days | Use error style after this many days |
toc.enable | bool | true | true / false | Global TOC switch |
toc.headingSelector | string | "h2,h3,h4,h5,h6" | CSS selector | Heading levels included in the TOC |
toc.collapseDepth | int | 0 | 0 = all collapsed; >0 = expand when children exist | TOC collapse depth |
post.advertisements[].id / text / link | string | — | — | Card identity, copy, link target |
post.advertisements[].image | string | — | site-local path | Card image (optional) |
post.advertisements[].background / background_dark | string | — | color value | Light/dark background pair |
post.advertisements[].colspan | int | 1 | column count | Card horizontal span |
post.advertisements[].enable | bool | true | true / false | Per-card toggle |
page.toc | bool | inherits global | true / false | Per-post TOC override |
page.reprintPolicy | string | inherits global | one of the 9 rules above | Per-post license override |
1.4 Boundaries & conflicts
- The outdated notice is off by default:
outdate.enable: false— unless you turn it on explicitly, no notice appears, which is easily mistaken for a broken feature. toc: falseis a string comparison: the template checkstheme.toc.enable && page.toc !== 'false', so non-boolean forms (e.g."False") do not take effect.- Ad slots and the TOC share the same sidebar area: many ad entries or a deep TOC make the sidebar visibly longer; on mobile the whole sidebar is hidden, so neither is visible.
- The copyright card is not the “append copyright on copy” feature:
post.copyrightcontrols the end-of-post card, whilepost.copy.copyrightcontrols the text appended when body content is copied — editing the wrong block has no effect.
1.5 Summary
- All five modules are single-line switches in the theme config; all are on by default except the outdated notice.
- Per-post granularity only has two override points:
tocandreprintPolicy. - After changing theme config you must run
hexo clean && hexo generate; in CI also syncuserConfig/_config.tmp.yml.
2. Page-level Widgets
Purpose: visualization widgets for the four aggregate pages (categories/tags/archives/about), all rendered automatically by theme generators and updated with content.
Learning path: How to enable (zero config) → All tunable keys (none) → Boundaries & conflicts
2.1 How to enable
Effect: the following pages automatically show charts / word clouds / timelines when the corresponding content exists:
| Page | Widget | Description |
|---|---|---|
/categories/ | Category radar | canvas radar chart showing post count distribution per category |
/tags/ | Tag cloud + word cloud | chip-style tag list; canvas word cloud with font size ∝ post count |
/archives/ | Archive timeline | vertical year/month timeline, dots + collapsible years |
/about/ | Site statistics charts | multiple canvas charts (posts/categories/tags/timeline etc.) |
/about/ | Site statistics numbers | post/category/tag counts (_partial/post/post-statis, auto-rendered) |
Corresponding config: none (the page itself must be created under source/ with layout set to categories / tags / archives / about).
2.2 Common options
Effect: chart colors follow dark mode switching; no separate setting needed.
Corresponding config: driven by CSS variables (see §7 Dark mode); there are no per-chart config keys.
2.3 All tunable keys
This group has no user-tunable config keys — all data comes from Hexo’s categories / tags / posts models, and appearance is controlled by themes/matery/source/css/.
2.4 Boundaries & conflicts
- Pages are not created automatically:
/categories/and friends require files such assource/categories/index.mdto exist. - Charts depend on canvas scripts; if the script is blocked by a CDN or lazy loading fails, the area degrades to blank without an error.
- Word clouds / radar charts get their information from post counts; with very few posts (<5) the charts show almost no difference.
2.5 Summary
- Zero config, zero maintenance — the trade-off is that appearance cannot be tuned.
- To change appearance you must edit CSS/templates; config cannot do it.
3. Responsive Breakpoints
Purpose: defines the phone / tablet / desktop / large-screen layout switch points and the content column width cap at each tier.
Learning path: How to enable (variables) → Common options (content width) → All tunable keys → Boundaries & conflicts
3.1 How to enable
Effect: as the window resizes, nav collapsing, sidebar folding and multi-column → single-column switching happen at the following thresholds.
Corresponding config (themes/matery/source/css/_variables/base.styl, Stylus variables):
$breakpoint-sm = 368px // extra small (phone portrait)
$breakpoint-md = 768px // tablet / phone landscape
$breakpoint-lg = 992px // desktop
$breakpoint-xl = 1200px // large desktop
$breakpoint-fun = 1400px // effects enable threshold (large screens)Layout behavior per breakpoint:
| Breakpoint | Layout behavior |
|---|---|
< 768px | nav collapses to hamburger menu, content single column, sidebar hidden |
768–992px | tablet layout, sidebar collapsed |
> 992px | desktop multi-column (content + sidebar + TOC) |
> 1400px | effects enabled (sakura/ripples etc.) |
The layout adapts via the Materialize grid — no manual maintenance needed.
3.2 Common options
Unified content width (2026-09-07)
Effect: the content area keeps “readable body, no infinite stretching on large screens” at every tier — width: 90% plus a per-screen max-width cap.
Corresponding config (_variables/base.styl, $content-max-* / $content-wide-max-*):
| Breakpoint | Standard (single-column) | Wide (multi-column) |
|---|---|---|
| FHD 993-1920px | 1125px | 1250px |
| 2K 1921-2560px | 1525px | 1750px |
| 4K 2561px+ | 1525px (cap) | 2250px |
Selection rule (mixin content-container(wide)):
- Single-column (no sidebar):
content-container()→ standard - Multi-column (sidebar/TOC present):
content-container(true)→ wide - Layouts must not hardcode max-width (always use the mixin)
wiki (multi-column) 4K content column grows from 899 to 1500px (+67%). Tested by
tools/tests/content-width.test.js(L2m).
3.3 All tunable keys
| Variable | Type | Default | Allowed values / range | Effect |
|---|---|---|---|---|
$breakpoint-sm | px | 368px | length | Extra-small threshold |
$breakpoint-md | px | 768px | length | Phone landscape / tablet threshold, nav collapse boundary |
$breakpoint-lg | px | 992px | length | Desktop multi-column boundary |
$breakpoint-xl | px | 1200px | length | Large-screen threshold |
$breakpoint-fun | px | 1400px | length | Effects enable threshold |
$content-max-* | px | see table above | length | Single-column width cap |
$content-wide-max-* | px | see table above | length | Multi-column width cap |
3.4 Boundaries & conflicts
- Breakpoint variables are referenced by many styl files; changing them affects nav, sidebar, grid and effects at once — the “change only one place” expectation does not hold.
- Content width must go through the
content-container()mixin; a hardcodedmax-widthin a layout fights the tier caps (truncated or too wide on large screens). - These are Stylus variables, not
_config.ymlconfig: after changing them you must recompile styles (build afterhexo clean). $breakpoint-funonly controls effects; it does not affect the layout column count.
3.5 Summary
- Five breakpoints + two width tiers make up all responsive behavior.
- Width priority: standard for single-column, wide for multi-column, decided uniformly by the mixin.
4. Galleries
Purpose: maintain all galleries (cover + description + image list) in one YAML file; the list page and lightbox inner pages are generated automatically.
Learning path: How to enable → Common options (three image forms / password lock) → All tunable keys → Boundaries & conflicts
4.1 How to enable
Effect: /galleries/ shows gallery list cards (with cover and description); the inner page is a lightGallery lightbox where image titles/descriptions appear as captions.
Corresponding config (data source source/_data/galleries.yml, single point of maintenance):
2020:
cover: /medias_webp/images/01.webp
description: New Year 2020
photos:
- url: /medias_webp/images/01.webp # form 1: full object (url/title/desc)
title: "New Year 2020"
- /medias_webp/images/02.webp # form 2: path only
- dir: /medias_webp/featureimages/ # form 3: directory, auto-scan all images
title_prefix: "Image"Corresponding config (create a gallery page):
hexo new gallery <name>Generates source/galleries/<name>/index.md (front-matter only needs title + layout: gallery).
4.2 Common options
Effect: entering the gallery asks for a password first; images render only after the correct one is entered.
Corresponding config (add password to the gallery page front-matter):
---
title: New Year 2020
layout: gallery
password: "********"
---Effect: every image in a directory is included; no need to list paths one by one.
Corresponding config: use the dir: form inside photos (see the third form in §4.1); title_prefix generates an automatic title prefix.
4.3 All tunable keys
| Key | Type | Default | Allowed values / range | Effect |
|---|---|---|---|---|
<gallery name> | map | — | any key name | Gallery identity (also the source of the page title) |
cover | string | — | site-local image path | List page cover |
description | string | — | text | List page description |
photos | array | — | object / string / dir object | Image list; the three forms can be mixed |
photos[].url / title / desc | string | — | — | Single image URL, title and description |
photos[].dir | string | — | directory path | Scan all images in that directory |
photos[].title_prefix | string | — | text | Auto-numbered title prefix |
page.password | string | — | any string | Gallery encryption |
4.4 Boundaries & conflicts
- Changing
galleries.ymlrequires clearing the cache: data changes hit Hexo’s incremental-cache misjudgement (site.databecomes undefined, page goes blank). In the container usetools/cicd.sh -d; locally userm -f db.json && hexo generate. - The gallery name is also the URL segment: renaming it changes the address and old links 404.
- The
dirform scans all images in the directory; covers or temporary images mixed in will be included too. - Encryption only protects inner pages; list page covers and descriptions stay public.
4.5 Summary
- One
galleries.ymlmanages every gallery; images support single-image / path / directory forms. - The password is gallery-level (the whole album), not per-image.
5. Search
Purpose: the navbar search popup with three engines (local / Algolia / Pagefind) that can be toggled independently and switched on the fly.
Learning path: How to enable → Common options (engine comparison / shortcuts / multilingual filtering / Pagefind build) → All tunable keys → Boundaries & conflicts
5.1 How to enable
Effect: a search box appears in the navbar; clicking opens the search panel with live results as you type; /search.json is the local index source; encrypted posts are automatically excluded from the index.
Corresponding config (theme config, search block, three engines):
search:
algolia:
enable: true # Algolia engine (applicationID/apiKey/indexName in theme config)
indexName: "blog"
local:
enable: true # local search: generator outputs /search.json at hexo generate
path: /search.json
field: [post, wiki] # search scope: post | page | wiki | all; array combinations allowed
content: true # index body content
pagefind:
enable: true # Pagefind static index (client-side search after build)
output_subdir: pagefind5.2 Common options
Three-engine config keys and the default engine
Effect: each engine has its trade-offs — local needs no external service, Algolia gives the best experience but depends on an external index, Pagefind is purely static with an index built at build time.
Corresponding config: the authoritative key names come from the search block in themes/matery/_config.yml (the template userConfig/_config.tmp.yml is the same source):
| Engine | Config block | Key params | Notes |
|---|---|---|---|
| local | search.local.* | enable / path / field / content / format: striptags / preload / trigger / top_n_per_article | the theme generator outputs search.json at build time; preload/trigger are not yet wired up, so the index is in practice always fetched when the search popup first opens |
| Algolia | search.algolia.* | enable / applicationID / apiKey / indexName / content_length / excerpt_length / batch_size / hits.per_page / labels | apiKey is the front-end search key (safe to expose); the write key lives in deploy.algolia_write_key (read only during build) |
| Pagefind | search.pagefind.* | enable / output_subdir: pagefind | scans public/ at build time to produce a static index; fully client-side, no external service |
Effect: one line decides which engine the site uses by default; a wrong value does not white-screen — it degrades.
Corresponding config (top-level search.default):
search:
default: "algolia" # algolia | local | pagefindsearch.default(valuealgolia/local/pagefind) selects the default engine; if the configured default is not enabled, the front end auto-degrades to the first enabled engine and logs aconsole.warn.- The Algolia client (
algoliasearch) is lazy-loaded: it is injected only when the search popup opens, not preloaded site-wide.
In-page engine switching and keyboard shortcuts
(Source: themes/matery/layout/_partial/common/search.ejs, _partial/script/search.ejs)
Effect: you can switch engines inside the popup and it re-searches immediately; the next open remembers your last choice; Ctrl+K opens it at any time.
Corresponding config: none (built-in behavior). Key points:
- The popup’s left-side engine icon
#searchEngineBtnopens a dropdown#searchEngineMenuto switch between local / algolia / pagefind; the dropdown button auto-hides when at most one engine is available. - Results render in real time for the current engine; switching triggers an immediate re-search with the current input value; the active engine is persisted in
localStorage(keysearch_engine). - Ctrl+K / Cmd+K opens the search popup, Esc closes the menu; the popup uses the native
popoverand light-dismisses on outside clicks. - IME compatibility: input events skip IME composition mid-states;
compositionendfalls back to searching with the full value (shared by all three engines).
Multilingual filtering and unified highlighting
(Source: themes/matery/source/js/search.js)
Effect: multilingual versions of the same document don’t flood the results — only the user’s preferred language remains; keywords are safely highlighted in results and on the target page.
Corresponding config: none (built-in behavior). Key points:
- Multilingual filtering: all three engines share
applyLangFilter()— results are grouped by path language prefix, the entry matching the user’s preferred language (localStoragekeywiki_lang, language list fromwindow.MATERY_LANG.langs) is returned first, missing entries fall back to the default language (default_lang), duplicates within a group are removed. - Unified highlighting: all three engines share the base class
_highlight()— keywords are escaped then wrapped in paired<mark class="search-keyword">tags (prevents XSS / unclosed tags); highlight HTML returned by Algolia is stripped by_safeHighlight()and re-highlighted locally. - Jump-to-page highlighting: result links append
?highlight=<keyword>; the post page’ssearch.ejstail script parses the parameter and highlights body text (skipping code blocks and links).
Pagefind build steps
Effect: public/pagefind/ holds a static index; search works client-side with no external service.
Corresponding config (scan public/ after hexo generate and before deployment; runs in the CI phase, see tools/CI.sh):
npx --no-install pagefind --site public --output-subdir pagefind \
|| npx --yes pagefind@1.5.2 --site public --output-subdir pagefindThe locally installed version is preferred; if not present, the pinned version pagefind@1.5.2 is downloaded once (prevents npx from pulling a floating latest).
5.3 All tunable keys
| Key | Type | Default | Allowed values / range | Effect |
|---|---|---|---|---|
search.default | string | algolia | algolia / local / pagefind | Default engine; degrades if not enabled |
search.algolia.enable | bool | true | true / false | Algolia engine switch |
search.algolia.applicationID | string | — | Algolia app ID | Index ownership |
search.algolia.apiKey | string | — | front-end search key | Read-only search (safe to expose) |
search.algolia.indexName | string | blog | index name | Which index to search |
search.algolia.content_length | int | — | character count | Truncation length of the body pushed to Algolia |
search.algolia.excerpt_length | int | — | character count | Result excerpt length |
search.algolia.batch_size | int | — | record count | Records per push batch |
search.algolia.hits.per_page | int | — | record count | Results per page |
search.algolia.labels | map | — | text | Copy for the result area |
search.local.enable | bool | true | true / false | Local search switch |
search.local.path | string | /search.json | path | Index output location |
search.local.field | array | [post, wiki] | post / page / wiki / all | Search scope |
search.local.content | bool | true | true / false | Index body content (false = titles only) |
search.local.format | string | striptags | striptags / raw | Index body format |
search.local.trigger | string | auto | auto / manual | Trigger mode (not yet wired up) |
search.local.top_n_per_article | int | 1 | -1 = all | Max matched snippets per post |
search.local.preload | bool | — | true / false | Preload (not yet wired up) |
search.pagefind.enable | bool | true | true / false | Pagefind engine switch |
search.pagefind.output_subdir | string | pagefind | directory name (must not start with an underscore) | Index output subdirectory |
5.4 Boundaries & conflicts
preload/triggerare configured but unimplemented keys: setting them changes nothing; the index is always fetched when the popup first opens.- Algolia has a hard 10KB per-record limit: an overlong body is rejected by the service (HTTP 400) and must be truncated via
content_length; Chinese counts ~3 bytes per character, so the limit is much lower than for English. output_subdirmust not start with an underscore: GitHub Pages (Jekyll) ignores directories starting with_, so the index is simply not published.- Pagefind must run after
hexo generate: reversing the order scans stale artifacts or an empty directory. - Enabling all three engines at once lets their configs mask each other’s problems: when debugging search issues, keep only one engine enabled first.
5.5 Summary
- The three engines are independent;
search.defaultpicks the preferred one and auto-degrades when it is not enabled. - local and Pagefind are both purely static; Algolia needs an extra index push.
field/content/content_lengthare the three main knobs controlling index size.
6. Comments
Purpose: Waline comments shared by posts, the message board and the friends page; supports Markdown/Emoji/likes/admin.
Learning path: How to enable → Common options (per-page toggle) → All tunable keys → Boundaries & conflicts
6.1 How to enable
Effect: a comment box appears at the bottom of posts and follows light/dark mode automatically; posting without login is allowed (per server config).
Corresponding config (theme config):
waline:
enable: true
serverURL: 'https://waline.17lai.site' # your Waline server
lang: zh-CN
dark: 'html[data-user-color-scheme="dark"]' # follow dark mode
login: enable
wordLimit: 1000
pageSize: 106.2 Common options
Effect: one post (or page) hides its comment area; other pages are unaffected.
Corresponding config (front-matter):
comments: false # true shows / false hides6.3 All tunable keys
| Key | Type | Default | Allowed values / range | Effect |
|---|---|---|---|---|
waline.enable | bool | true | true / false | Comment area master switch |
waline.serverURL | string | — | server URL | Where comment data lives |
waline.lang | string | zh-CN | language code | UI language |
waline.dark | string | html[data-user-color-scheme="dark"] | CSS selector | Style applied in dark mode |
waline.login | string | enable | enable / other values unverified | Whether login is required |
waline.wordLimit | int | 1000 | character count | Max characters per comment |
waline.pageSize | int | 10 | record count | Comments per page |
waline.avatar | string | mp | ''/mp/identicon/monsterid/wavatar/retro/hide | Avatar source |
page.comments | bool | inherits global | true / false | Per-page toggle |
6.4 Boundaries & conflicts
- Client and server versions must match: a Waline version mismatch makes the comment box load but submissions fail.
- A wrong
serverURLdoes not error: the box just stays blank or loading forever — check the browser network panel. - Dark mode depends on the
darkselector: if the theme’sdata-user-color-schemeattribute is changed, the comment box stays light. - Both
walineandvalineconfig blocks exist; which one is used depends onenable. Enabling both produces two comment boxes.
6.5 Summary
- Enabling needs only two lines:
enable+serverURL; the rest is experience tuning. - Per-page granularity uses front-matter
comments.
7. Dark Mode
Purpose: a whole set of CSS variables switched by the
[data-user-color-scheme]attribute, covering body text, images, charts and comments.Learning path: How to enable → Common options (three default modes) → All tunable keys → Boundaries & conflicts
7.1 How to enable
Effect: a light/dark toggle button appears; by default it switches automatically by system preference or local time, and remembers the user’s manual choice.
Corresponding config (theme config):
dark_mode:
enable: true
default: auto # auto | light | dark7.2 Common options
Effect: the three default strategies behave as follows.
Corresponding config: dark_mode.default above.
- auto: prefers
prefers-color-scheme, then auto-enters dark between 18:00–6:00 local time - light / dark: fixed initial mode; manual switching overrides it
- The manual toggle overrides the default mode (remembers the user’s choice)
7.3 All tunable keys
| Key | Type | Default | Allowed values / range | Effect |
|---|---|---|---|---|
dark_mode.enable | bool | true | true / false | Whether to provide the toggle and dark styles |
dark_mode.default | string | auto | auto / light / dark | Initial mode |
image.light_filter / light_filter_dark | string | brightness(1) / brightness(0.92) | CSS filter | Image filter in light/dark |
image.card_opacity / card_opacity_dark | string | 0.85 / 0.7 | 0–1 | Card opacity in light/dark |
7.4 Boundaries & conflicts
- Dark values do not come from a single
_config.ymlsource: colors are defined in pairs inside the[data-user-color-scheme="dark"]block ofcolor-schema.styl; changing only one side produces a light/dark mismatch. autodecides the time window from the visitor’s local time, not the site timezone; users in different regions may see different modes at the same moment.- Third-party widgets (comments, ECharts) have their own dark-mode logic; new widgets must hook into
data-user-color-schemeseparately. - The manual choice is stored in the browser; clearing site data returns to the default mode.
7.5 Summary
- One attribute (
data-user-color-scheme) + one set of CSS variables = site-wide dark mode. - Any new hand-drawn widget needs both light and dark variables, otherwise dark mode shows “white patches”.
8. Encryption
Purpose: password protection at four granularities — post / gallery / content snippet / whole wiki — decrypted in the browser via WebCrypto.
Learning path: How to enable → Common options (four methods / wiki-wide encryption / in-page front-matter) → All tunable keys → Boundaries & conflicts
8.1 How to enable
Effect: an encrypted post page shows the decryption UI (#hbePass); the body renders after the correct password is entered; a wrong password shows the error copy.
Corresponding config (in-house HBE v4 system, de-pluginized since 2026-08-09 replacing hexo-blog-encrypt; AES-256-GCM + PBKDF2 with 250k iterations, unified across posts / galleries / snippets / wikis. Front-end WebCrypto decryption; the hexo-blog-decrypt event triggers a theme refresh. Theme encrypt section):
encrypt:
enable: true
abstract: Something is encrypted, enter the password to view.
message: Hello, password required here.
tags: # tag-based encryption: posts with these tags encrypt automatically
- {name: 私人, password: "********"}
wrong_pass_message: Sorry, that password doesn't look right. Please try again.
autoSave: true # cache the derived key in localStorage (1-day TTL), no password on refresh8.2 Common options
Four encryption methods
Effect: from “encrypt a whole post by tag” to “hide just one paragraph” — four granularities in total.
Corresponding config:
| Method | Usage | Notes |
|---|---|---|
| Tag encryption | Tag a post with one of the tags in encrypt.tags | Automatically encrypts the full post |
| Per-post encryption | password: "********" in front-matter | Full-post encryption |
| Content snippet encryption | encrypt tag (password + title + abstract) | Paragraph-level encryption, supports nested tags inside (2026-09-07 scheme Y) |
| Wiki-wide encryption | Add encrypt_password to {wiki}-sidebar.yml | One password for the entire wiki, shared DK across pages (2026-09-07) |
Full form of snippet encryption (parameters: password, title, abstract):
{% encrypt password "Title" "Abstract" %}markdown content{% endencrypt %}Wiki-wide encryption
Effect: encrypts the middle content + right TOC while keeping the left navigation visible (effectively a title bar); decrypting any page unlocks all language versions of that wiki (1-day TTL).
Corresponding config (any {wiki}-sidebar.yml, e.g. source/_data/dev-sidebar.yml; unified encrypt_ prefix):
encrypt_password: "password for the entire wiki" # required
encrypt_message: "This document is password-protected" # optional: prompt text
encrypt_wpm: "Wrong password" # optional: error message
encrypt_placeholder: "Enter password" # optional: input placeholder
encrypt_button_text: "Unlock" # optional: button textWiki page front-matter checklist (2026-09-03)
Effect: wiki pages can turn Mermaid, MathJax, anchors, Prism plugins and ECharts on as needed, or disable the TOC/comments/encryption for the page.
Corresponding config: wiki pages (layout: wiki) support the same front-matter as posts; common options:
| front-matter | Effect |
|---|---|
mermaid: true | Enable Mermaid flowcharts / sequence diagrams |
mathjax: true | Enable MathJax formulas |
toc: false | Disable the page TOC |
comment: false | Disable comments on this page |
anchorjs: false | Disable heading anchors |
treeview: true | Enable Prism treeview code-tree plugin |
autolinker: true | Enable Prism autolinker link plugin |
diffhighlight: true | Enable Prism diff highlight plugin |
echarts: true | Enable ECharts charts (requires chart containers in the body) |
password: "********" | Encrypt this page (same unlock UX as posts) |
ECharts charts (unified 2026-09-03)
Effect: interactive charts appear in the body, auto-adapting to light/dark mode; GL charts such as 3D/globe also work.
Corresponding config (add echarts: true in front-matter; loads libs echarts (latest, currently default v6.1.0) + echarts-gl 2.1.0):
{% echarts width height %}
{ "xAxis": { "type": "category", "data": ["A","B"] }, "yAxis": { "type": "value" }, "series": [{ "type": "bar", "data": [1,2] }] }
{% endecharts %}- Charts in posts: the
echartstag (arguments are width then height; width defaults to 100%, height to 400px) + option JSON - Light/dark: auto-adapts (init with the current theme, rebuilt on toggle)
- GL charts: automatically available when the option contains grid3D/globe etc. (echarts-gl is already loaded)
- Note: echarts 6 requires an explicit
typeon xAxis (category/value)
8.3 All tunable keys
| Key | Type | Default | Allowed values / range | Effect |
|---|---|---|---|---|
encrypt.enable | bool | true | true / false | Encryption system master switch |
encrypt.abstract | string | see above | text | Abstract shown while locked |
encrypt.message | string | see above | text | Unlock box prompt |
encrypt.tags | array | — | {name, password} list | Tag-based bulk encryption |
encrypt.wrong_pass_message | string | see above | text | Wrong-password message |
encrypt.autoSave | bool | true | true / false | Derived key cache (1-day TTL) |
page.password | string | — | any string | Per-post / per-page encryption |
<wiki>-sidebar.yml: encrypt_password | string | — | any string | Whole-wiki password (presence enables it) |
encrypt_message / encrypt_wpm / encrypt_placeholder / encrypt_button_text | string | — | text | Wiki unlock box copy |
page.echarts | bool | false | true / false | Load the ECharts runtime |
8.4 Boundaries & conflicts
enable: falsemakes already-encrypted content unreadable: the ciphertext assets remain, but the front end no longer loads the decryption logic — the result is a blank area or raw ciphertext. Re-enabling restores it.autoSaveis convenience and risk: the decryption key is cached inlocalStorage(1 day), which on a shared device means one day without a password.- The wiki password and post passwords are independent: after changing a wiki’s
encrypt_password, browsers that already unlocked it can still read old pages with the old key (within the TTL). - The
hexo-blog-encryptplugin is deprecated: only this theme’sencryptsection is read; configuring per the old plugin docs has no effect. - Missing one
rawtag in snippet encryption causes anunknown block tagerror at build time (the examples on this page already include it). - Asset minification (2026-09-25): hbe encryption assets now live in
source/libs/hbe/and go through the static pipeline, sohexo-minifycompresses them (previously bypassed).
8.5 Summary
- Four granularities: tag bulk, per-post, snippet, whole wiki.
- Everything decrypts on the front end — it guards against casual access, not server-side authorization: both ciphertext and key-derivation parameters live in the page.
- Wiki unlock state is shared across pages with a 1-day TTL.
Publishing & Standalone
9. RSS / Sitemap
Purpose: output three feed types and two sitemaps for readers and search engines.
Learning path: How to enable → Common options (entry count / output filename) → All tunable keys → Boundaries & conflicts
9.1 How to enable
Effect: the site root generates three feeds — /rss.xml, /atom.xml, /feed.json — plus two sitemaps — /sitemap.xml, /baidusitemap.xml.
Corresponding config (root _config.yml, hexo-feed + hexo-generator-sitemap):
feed: # independent switches for the three feed types
rss:
enable: true
output: "rss.xml"
atom:
enable: true
output: "atom.xml"
jsonFeed:
enable: true
output: "feed.json"
limit: 10
sitemap: # general sitemap
path: sitemap.xml
baidusitemap: # Baidu sitemap
path: baidusitemap.xml9.2 Common options
Effect: feeds keep only the latest 20 posts, shrinking each file.
Corresponding config:
feed:
limit: 20Effect: change the feed output filenames (e.g. unify under /feed/rss.xml).
Corresponding config: edit feed.rss.output / feed.atom.output / feed.jsonFeed.output (the RSS template is themes/matery/layout/_partial/rss.ejs).
9.3 All tunable keys
| Key | Type | Default | Allowed values / range | Effect |
|---|---|---|---|---|
feed.rss.enable | bool | true | true / false | Output RSS 2.0 |
feed.rss.output | string | rss.xml | filename | RSS output path |
feed.atom.enable | bool | true | true / false | Output Atom |
feed.atom.output | string | atom.xml | filename | Atom output path |
feed.jsonFeed.enable | bool | true | true / false | Output JSON Feed |
feed.jsonFeed.output | string | feed.json | filename | JSON Feed output path |
feed.limit | int | 10 | post count | Feed entry limit |
sitemap.path | string | sitemap.xml | path | General sitemap |
baidusitemap.path | string | baidusitemap.xml | path | Baidu sitemap |
9.4 Boundaries & conflicts
- These settings live in the root
_config.yml, not the theme config; putting them in the theme config has no effect. - Generators output at build time; without
hexo clean, old files stay inpublic/. - Encrypted posts still appear in feeds (title/summary) — only the body is encrypted; to exclude them entirely you must filter in the generator.
- Changing an
outputpath makes the old feed address 404 immediately, cutting off existing readers.
9.5 Summary
- The three feed types have independent switches;
limitcontrols the entry count. - Two sitemaps serve general search engines and Baidu respectively.
10. PWA
Purpose: turn the site into an installable, offline-capable PWA; each build rotates the cache version and silently refreshes clients once.
Learning path: How to enable → Common options (SW version management) → All tunable keys → Boundaries & conflicts
10.1 How to enable
Effect: an install entry appears in the browser address bar (manifest + theme color take effect); cached pages still open offline; after a site update the client auto-refreshes once to the new version.
Corresponding config (theme config):
pwa:
enable: trueuserConfig/sw.tmp.js is the Service Worker template: CI injects the offline cache version (17lai-cache-{timestamp}) and generates source/sw.js.
10.2 Common options
SW version management details
(Source: userConfig/sw.tmp.js, themes/matery/layout/_partial/common/head.ejs, tools/cicd.sh)
Effect: after a new deployment, users need no manual refresh and are not interrupted by popups; old caches are cleaned up automatically.
Corresponding config: none (CI and templates cooperate). Key points:
- Template → artifact: during CI,
tools/cicd.sh’sinject_pwa_sw()first copiesuserConfig/sw.tmp.jstosource/sw.js, then injects placeholders withsed; the artifact is published as/sw.jsat the site root. - Cache key / version injection: the template uses the literal
17lai-cache-{uniqueIdentifier}as the cache key (prefix17lai-cache-); CI replaces the placeholder with a build timestamp (date '+%Y%m%d%H%M%S', i.e.offline_version), producing a unique key like17lai-cache-20260913181700— a new version on every build. The same step also injects{cdnUrl}/{cdnPathVersion}/{cdnPathLatest}/{urlVersion}placeholders. - Client auto-refresh once (
head.ejs, registered as anasyncscript whentheme.pwa.enableis true,scope: '/'; skipped onlocalhostto avoid stale-cache hits during local development):- After registration, sends a
checkIdentifiermessage to the SW viaMessageChannel, retrieves the current cache version, and records the baseline. - On
updatefound→ new SWinstalled(after pre-cacheaddAllcompletes), and oncontrollerchange(SW takes over), triggerscheckVersionAndRefresh(). - Only reloads (
window.location.reload(), delayed 500ms foractivateto finish) when the cache version changes; arefreshedguard ensures one reload per page, preventing Vercel redeploy-triggered reload loops — no popup, no manual refresh.
- After registration, sends a
- Activation and old-cache cleanup (SW template): the
installevent pre-cachescacheListthen callsself.skipWaiting(); theactivateevent iteratescaches.keys(), deletes old caches with the17lai-cache-prefix that don’t match the current cache key, re-runsaddAll, then callsself.clients.claim()to take over all pages. - Minified backup: in release mode the uncompressed
sw.jsis backed up touserConfig/sw.js; after the build, the minified version is backed up touserConfig/sw.min.js. Continue mode reusessw.min.jsto keep minified artifacts consistent (falls back to the template version if missing).
10.3 All tunable keys
| Key / file | Type | Default | Allowed values / range | Effect |
|---|---|---|---|---|
pwa.enable | bool | true | true / false | Register the SW and manifest |
userConfig/sw.tmp.js | template | — | — | SW source (CI injects the version then outputs source/sw.js) |
{uniqueIdentifier} | placeholder | build timestamp | YYYYMMDDHHMMSS | Cache key, changes every build |
{cdnUrl} / {cdnPathVersion} / {cdnPathLatest} / {urlVersion} | placeholder | injected by CI | — | Asset addresses inside the SW |
userConfig/sw.min.js | file | — | — | Minified artifact reused in continue mode |
10.4 Boundaries & conflicts
- SW caching is the most common cause of “changes don’t apply”:
localhostskips registration, but visiting the test domain by hostname hits the old cache — unregister the SW / clear site data before debugging. - An unchanged version does not trigger an update: changing content without rebuilding (or reusing the old version with
-c) keeps the same cache key, so clients may keep the old cache. - If template placeholders are not injected (running
hexo generatelocally),{cdnUrl}etc. stay as literals insw.js, causing cache requests to 404. - Skipping registration on
localhostis intentional — don’t debug “why is there no SW” locally.
10.5 Summary
- PWA has only one switch; the real complexity is the version-injection chain in
sw.tmp.js. - Cache key = build timestamp, so “every deployment is a new version”.
11. Standalone Pages
Purpose: dedicated layout pages provided by the theme (media/short film/message board/friends/contact/404); the page body is written in md and the structure is rendered by the template.
Learning path: How to enable (layout by layout) → Common options (data sources / front-matter) → All tunable keys → Boundaries & conflicts
11.1 How to enable
The following pages have dedicated layout templates in the theme. Create the page under source/ (set layout in front-matter); the page body lives in the md file and the template renders it.
av media page (layout: av)
⚠️ DEPRECATED (2026-09-12): the
avlayout had no practical use and has been removed
from the theme (themes/matery/layout/av.ejsdeleted;source/av/is no longer created).
The following is kept for historical reference only — do not create this page again.
Effect (historical design): a media/resource-sharing page structured like the About page — music player + video + my gallery + resource-sharing body.
Corresponding config (historical data sources, no template consumes them now):
theme.music(music player, see Interactions & Visual §9)theme.video(video player, see Interactions & Visual §10)theme.myGallery(my gallery, see Sidebar Widgets §8)page.content(page body, resource-sharing list)
How the page was created back then (not created in this project):
hexo new page avsource/av/index.md front-matter:
---
title: AV Resources
layout: av
---movies page (layout: movies)
Effect: an inspirational short-film page containing a Bilibili iframe player (the address is hardcoded in the template).
Corresponding config (the project already has source/movies/index.md):
---
title: Videos
layout: movies
---Data source: none — the film address is hardcoded in the iframe src inside themes/matery/layout/movies.ejs; changing the film requires editing the template.
msg message board (layout: msg)
Effect: a message board — body (blog timeline etc.) + letter envelope component + comment area; the envelope has an open animation and message-form hints (styles in letter.styl, copy via i18n letter.*).
Corresponding config (the project already has source/msg/index.md):
---
title: Message Board
layout: msg
toc: false # disable TOC (template checks theme.toc.enable && page.toc !== 'false')
comment: waline
---Comments toggle: the template injects comments via inject_point('pageComments'); enable with front-matter comment: waline (or comments: true).
friends link page (layout: friends)
Effect: a friend-link card wall (Masonry waterfall); card background colors cycle frind-card1~frind-card10 in order; the page body renders below the friend list, and comments render via the linksComments injection point.
Corresponding config (the project already has source/friends/index.md):
---
title: 'For My Friends!'
layout: friends
comment: waline
---Data source (source/_data/friends.yml, a plain array read by the template via site.data.friends):
- name: Friend name # required, card title
url: https://example.com # required, link target
avatar: /favicon.png # required, avatar
introduction: One-liner # required
title: Visit # optional, button textcontact page (layout: contact — ⚠️ not implemented in the active theme, do not use)
Note:
contact.ejsdoes not exist in the active themethemes/matery/layout/(only the disabled upstream reference theme has it), solayout: contactwill not render. The following is kept for historical context only.
Effect (design intent): a contact page — page body + barrage interaction (text/link/speed) + comment area.
Corresponding config (historical design): LeanCloud (AV)-backed barrager; the barrage form shows when either valine or waline is enabled (theme.valine.enable or theme.waline.enable); customer-service widgets (daovoice / tidio / tuxiaochao) are covered in Interactions & Visual §14.
How the page was created back then (not created in this project):
hexo new page contactsource/contact/index.md front-matter:
---
title: Contact
layout: contact
---404 page (layout: 404)
Effect: a not-found notice + search entry + 8-second countdown redirect to home; the banner image switches daily (/medias_webp/banner/{0-6}.webp).
Corresponding config (the project already has source/404.md):
---
title: 404
layout: 404
excerpt: "Oops~,我崩溃了!找不到你想要的页面 :(" # shown as the page description (sample copy is Chinese — change it as needed)
---11.2 Common options
Effect: control whether a standalone page shows a TOC and comments.
Corresponding config (page front-matter):
toc: false # disable this page's TOC
comment: waline # mount Waline comments (or use comments: true)Effect: friend-link cards change color by list order; no styles needed.
Corresponding config: the order of entries in friends.yml is the color order (cycles frind-card1~frind-card10).
11.3 All tunable keys
| layout value | Page | Template | Status |
|---|---|---|---|
av | /av/ | deleted (av.ejs removed) | Deprecated (2026-09-12) |
movies | /movies/ | themes/matery/layout/movies.ejs | Available (video address hardcoded) |
msg | /msg/ | themes/matery/layout/msg.ejs | Available |
friends | /friends/ | themes/matery/layout/friends.ejs | Available (data source friends.yml) |
contact | /contact/ | does not exist | Not implemented, do not use |
404 | /404.html | themes/matery/layout/404.ejs | Available |
page.toc | each standalone page | — | true / false, disables the TOC |
page.comment / page.comments | each standalone page | — | Enable comments |
page.excerpt | 404 etc. | — | Page description copy |
11.4 Boundaries & conflicts
layout: avandlayout: contactare both dead config: writing them does not error, it just falls back to the default page template (or blank), which is easily misdiagnosed as a style issue.moviescontent is not configurable: the video address lives in the.ejs; changing the film requires theme code changes (a code change — release with-r).- The
frind-card*typo is frozen: restyling with the correct spellingfriend-cardwill not match. - Standalone pages also need a page under
source/: config alone without an md file means the route does not exist. - Page-level
toc/commentonly work for layouts that support the injection points.
11.5 Summary
- Four and a half are currently usable:
movies,msg,friends,404(avdeleted,contactnot implemented). - Only
friendshas a fixed data source (source/_data/friends.yml); the rest rely on template hardcoding or injection points. - Creating a page takes three things:
hexo new page <name>+ front-matterlayout+ (if needed) a data file.
Appendix: Layout Feature Quick Reference
| Feature | Location | Config | Description |
|---|---|---|---|
| Prev/next nav | post bottom | theme post.prev_next | adjacent posts by date |
| Copyright | post bottom | theme post.copyright (with license sub-key) | per-post override via front-matter reprintPolicy |
| Outdated notice | post top | theme post.outdate | off by default, graded by days |
| TOC | post sidebar | theme toc | per-post off via front-matter toc: false |
| Ad slots | sidebar | theme post.advertisements | array of cards, individually toggleable |
| Category radar | /categories/ | auto-rendered | no config |
| Tag cloud/word cloud | /tags/ | auto-rendered | no config |
| Archive timeline | /archives/ | auto-rendered | no config |
| About charts | /about/ | auto-rendered | no config |
| Responsive breakpoints | global | $breakpoint-* variables in base.styl | 368/768/992/1200/1400 |
| Galleries | /galleries/ | source/_data/galleries.yml | pages via hexo new gallery |
| Search | navbar | theme search (algolia/local/pagefind) | three engines independently toggleable |
| Comments | posts/message pages etc. | theme waline | front-matter comments toggles |
| Dark mode | global | theme dark_mode | auto follows system + time window |
| Encryption | post pages | root encrypt | tag-based or front-matter password |
| RSS/Sitemap | root paths | root feed / sitemap / baidusitemap | three feeds + two sitemaps |
| PWA | global | theme pwa + userConfig/sw.tmp.js | offline cache + installable |
| Standalone pages | /movies/ /msg/ /friends/ /404 | create page under source/ + front-matter layout | four dedicated templates, see §11 (/av/ removed, /contact/ template not implemented) |