Loading...

Loading...

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 the userConfig/_config.tmp.yml template 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 as themes/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: true

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 days

TOC

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 collapsed

Ad 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 it

1.2 Common options

Effect: one post hides its TOC; other posts are unaffected.

Corresponding config (front-matter):

toc: false

Effect: 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-NonCommercial

Available 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

KeyTypeDefaultAllowed values / rangeEffect
post.prev_next.enablebooltruetrue / falsePrev/next cards at the end of the post
post.copyright.enablebooltruetrue / falseCopyright card at the end of the post
post.copyright.licensestringcc_by_nc_saone of the 9 rules aboveDefault reprint rule
post.outdate.enableboolfalsetrue / falseMaster switch for the outdated notice
post.outdate.warning_dayint365daysUse warning style after this many days
post.outdate.error_dayint3650daysUse error style after this many days
toc.enablebooltruetrue / falseGlobal TOC switch
toc.headingSelectorstring"h2,h3,h4,h5,h6"CSS selectorHeading levels included in the TOC
toc.collapseDepthint00 = all collapsed; >0 = expand when children existTOC collapse depth
post.advertisements[].id / text / linkstring——Card identity, copy, link target
post.advertisements[].imagestring—site-local pathCard image (optional)
post.advertisements[].background / background_darkstring—color valueLight/dark background pair
post.advertisements[].colspanint1column countCard horizontal span
post.advertisements[].enablebooltruetrue / falsePer-card toggle
page.tocboolinherits globaltrue / falsePer-post TOC override
page.reprintPolicystringinherits globalone of the 9 rules abovePer-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: false is a string comparison: the template checks theme.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.copyright controls the end-of-post card, while post.copy.copyright controls 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: toc and reprintPolicy.
  • After changing theme config you must run hexo clean && hexo generate; in CI also sync userConfig/_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:

PageWidgetDescription
/categories/Category radarcanvas radar chart showing post count distribution per category
/tags/Tag cloud + word cloudchip-style tag list; canvas word cloud with font size ∝ post count
/archives/Archive timelinevertical year/month timeline, dots + collapsible years
/about/Site statistics chartsmultiple canvas charts (posts/categories/tags/timeline etc.)
/about/Site statistics numberspost/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 as source/categories/index.md to 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:

BreakpointLayout behavior
< 768pxnav collapses to hamburger menu, content single column, sidebar hidden
768–992pxtablet layout, sidebar collapsed
> 992pxdesktop multi-column (content + sidebar + TOC)
> 1400pxeffects 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-*):

BreakpointStandard (single-column)Wide (multi-column)
FHD 993-1920px1125px1250px
2K 1921-2560px1525px1750px
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

VariableTypeDefaultAllowed values / rangeEffect
$breakpoint-smpx368pxlengthExtra-small threshold
$breakpoint-mdpx768pxlengthPhone landscape / tablet threshold, nav collapse boundary
$breakpoint-lgpx992pxlengthDesktop multi-column boundary
$breakpoint-xlpx1200pxlengthLarge-screen threshold
$breakpoint-funpx1400pxlengthEffects enable threshold
$content-max-*pxsee table abovelengthSingle-column width cap
$content-wide-max-*pxsee table abovelengthMulti-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 hardcoded max-width in a layout fights the tier caps (truncated or too wide on large screens).
  • These are Stylus variables, not _config.yml config: after changing them you must recompile styles (build after hexo clean).
  • $breakpoint-fun only 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

KeyTypeDefaultAllowed values / rangeEffect
<gallery name>map—any key nameGallery identity (also the source of the page title)
coverstring—site-local image pathList page cover
descriptionstring—textList page description
photosarray—object / string / dir objectImage list; the three forms can be mixed
photos[].url / title / descstring——Single image URL, title and description
photos[].dirstring—directory pathScan all images in that directory
photos[].title_prefixstring—textAuto-numbered title prefix
page.passwordstring—any stringGallery encryption

4.4 Boundaries & conflicts

  • Changing galleries.yml requires clearing the cache: data changes hit Hexo’s incremental-cache misjudgement (site.data becomes undefined, page goes blank). In the container use tools/cicd.sh -d; locally use rm -f db.json && hexo generate.
  • The gallery name is also the URL segment: renaming it changes the address and old links 404.
  • The dir form 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.yml manages every gallery; images support single-image / path / directory forms.
  • The password is gallery-level (the whole album), not per-image.

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: pagefind

5.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):

EngineConfig blockKey paramsNotes
localsearch.local.*enable / path / field / content / format: striptags / preload / trigger / top_n_per_articlethe 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
Algoliasearch.algolia.*enable / applicationID / apiKey / indexName / content_length / excerpt_length / batch_size / hits.per_page / labelsapiKey is the front-end search key (safe to expose); the write key lives in deploy.algolia_write_key (read only during build)
Pagefindsearch.pagefind.*enable / output_subdir: pagefindscans 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 | pagefind
  • search.default (value algolia / 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 a console.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 #searchEngineBtn opens a dropdown #searchEngineMenu to 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 (key search_engine).
  • Ctrl+K / Cmd+K opens the search popup, Esc closes the menu; the popup uses the native popover and light-dismisses on outside clicks.
  • IME compatibility: input events skip IME composition mid-states; compositionend falls 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 (localStorage key wiki_lang, language list from window.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’s search.ejs tail 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 pagefind

The 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

KeyTypeDefaultAllowed values / rangeEffect
search.defaultstringalgoliaalgolia / local / pagefindDefault engine; degrades if not enabled
search.algolia.enablebooltruetrue / falseAlgolia engine switch
search.algolia.applicationIDstring—Algolia app IDIndex ownership
search.algolia.apiKeystring—front-end search keyRead-only search (safe to expose)
search.algolia.indexNamestringblogindex nameWhich index to search
search.algolia.content_lengthint—character countTruncation length of the body pushed to Algolia
search.algolia.excerpt_lengthint—character countResult excerpt length
search.algolia.batch_sizeint—record countRecords per push batch
search.algolia.hits.per_pageint—record countResults per page
search.algolia.labelsmap—textCopy for the result area
search.local.enablebooltruetrue / falseLocal search switch
search.local.pathstring/search.jsonpathIndex output location
search.local.fieldarray[post, wiki]post / page / wiki / allSearch scope
search.local.contentbooltruetrue / falseIndex body content (false = titles only)
search.local.formatstringstriptagsstriptags / rawIndex body format
search.local.triggerstringautoauto / manualTrigger mode (not yet wired up)
search.local.top_n_per_articleint1-1 = allMax matched snippets per post
search.local.preloadbool—true / falsePreload (not yet wired up)
search.pagefind.enablebooltruetrue / falsePagefind engine switch
search.pagefind.output_subdirstringpagefinddirectory name (must not start with an underscore)Index output subdirectory

5.4 Boundaries & conflicts

  • preload / trigger are 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_subdir must 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.default picks 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_length are 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: 10

6.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 hides

6.3 All tunable keys

KeyTypeDefaultAllowed values / rangeEffect
waline.enablebooltruetrue / falseComment area master switch
waline.serverURLstring—server URLWhere comment data lives
waline.langstringzh-CNlanguage codeUI language
waline.darkstringhtml[data-user-color-scheme="dark"]CSS selectorStyle applied in dark mode
waline.loginstringenableenable / other values unverifiedWhether login is required
waline.wordLimitint1000character countMax characters per comment
waline.pageSizeint10record countComments per page
waline.avatarstringmp''/mp/identicon/monsterid/wavatar/retro/hideAvatar source
page.commentsboolinherits globaltrue / falsePer-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 serverURL does not error: the box just stays blank or loading forever — check the browser network panel.
  • Dark mode depends on the dark selector: if the theme’s data-user-color-scheme attribute is changed, the comment box stays light.
  • Both waline and valine config blocks exist; which one is used depends on enable. 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 | dark

7.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

KeyTypeDefaultAllowed values / rangeEffect
dark_mode.enablebooltruetrue / falseWhether to provide the toggle and dark styles
dark_mode.defaultstringautoauto / light / darkInitial mode
image.light_filter / light_filter_darkstringbrightness(1) / brightness(0.92)CSS filterImage filter in light/dark
image.card_opacity / card_opacity_darkstring0.85 / 0.70–1Card opacity in light/dark

7.4 Boundaries & conflicts

  • Dark values do not come from a single _config.yml source: colors are defined in pairs inside the [data-user-color-scheme="dark"] block of color-schema.styl; changing only one side produces a light/dark mismatch.
  • auto decides 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-scheme separately.
  • 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 refresh

8.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:

MethodUsageNotes
Tag encryptionTag a post with one of the tags in encrypt.tagsAutomatically encrypts the full post
Per-post encryptionpassword: "********" in front-matterFull-post encryption
Content snippet encryptionencrypt tag (password + title + abstract)Paragraph-level encryption, supports nested tags inside (2026-09-07 scheme Y)
Wiki-wide encryptionAdd encrypt_password to {wiki}-sidebar.ymlOne 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 text

Wiki 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-matterEffect
mermaid: trueEnable Mermaid flowcharts / sequence diagrams
mathjax: trueEnable MathJax formulas
toc: falseDisable the page TOC
comment: falseDisable comments on this page
anchorjs: falseDisable heading anchors
treeview: trueEnable Prism treeview code-tree plugin
autolinker: trueEnable Prism autolinker link plugin
diffhighlight: trueEnable Prism diff highlight plugin
echarts: trueEnable 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 echarts tag (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 type on xAxis (category/value)

8.3 All tunable keys

KeyTypeDefaultAllowed values / rangeEffect
encrypt.enablebooltruetrue / falseEncryption system master switch
encrypt.abstractstringsee abovetextAbstract shown while locked
encrypt.messagestringsee abovetextUnlock box prompt
encrypt.tagsarray—{name, password} listTag-based bulk encryption
encrypt.wrong_pass_messagestringsee abovetextWrong-password message
encrypt.autoSavebooltruetrue / falseDerived key cache (1-day TTL)
page.passwordstring—any stringPer-post / per-page encryption
<wiki>-sidebar.yml: encrypt_passwordstring—any stringWhole-wiki password (presence enables it)
encrypt_message / encrypt_wpm / encrypt_placeholder / encrypt_button_textstring—textWiki unlock box copy
page.echartsboolfalsetrue / falseLoad the ECharts runtime

8.4 Boundaries & conflicts

  • enable: false makes 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.
  • autoSave is convenience and risk: the decryption key is cached in localStorage (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-encrypt plugin is deprecated: only this theme’s encrypt section is read; configuring per the old plugin docs has no effect.
  • Missing one raw tag in snippet encryption causes an unknown block tag error 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, so hexo-minify compresses 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.xml

9.2 Common options

Effect: feeds keep only the latest 20 posts, shrinking each file.

Corresponding config:

feed:
  limit: 20

Effect: 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

KeyTypeDefaultAllowed values / rangeEffect
feed.rss.enablebooltruetrue / falseOutput RSS 2.0
feed.rss.outputstringrss.xmlfilenameRSS output path
feed.atom.enablebooltruetrue / falseOutput Atom
feed.atom.outputstringatom.xmlfilenameAtom output path
feed.jsonFeed.enablebooltruetrue / falseOutput JSON Feed
feed.jsonFeed.outputstringfeed.jsonfilenameJSON Feed output path
feed.limitint10post countFeed entry limit
sitemap.pathstringsitemap.xmlpathGeneral sitemap
baidusitemap.pathstringbaidusitemap.xmlpathBaidu 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 in public/.
  • 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 output path makes the old feed address 404 immediately, cutting off existing readers.

9.5 Summary

  • The three feed types have independent switches; limit controls 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: true

userConfig/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’s inject_pwa_sw() first copies userConfig/sw.tmp.js to source/sw.js, then injects placeholders with sed; the artifact is published as /sw.js at the site root.
  • Cache key / version injection: the template uses the literal 17lai-cache-{uniqueIdentifier} as the cache key (prefix 17lai-cache-); CI replaces the placeholder with a build timestamp (date '+%Y%m%d%H%M%S', i.e. offline_version), producing a unique key like 17lai-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 an async script when theme.pwa.enable is true, scope: '/'; skipped on localhost to avoid stale-cache hits during local development):
    1. After registration, sends a checkIdentifier message to the SW via MessageChannel, retrieves the current cache version, and records the baseline.
    2. On updatefound → new SW installed (after pre-cache addAll completes), and on controllerchange (SW takes over), triggers checkVersionAndRefresh().
    3. Only reloads (window.location.reload(), delayed 500ms for activate to finish) when the cache version changes; a refreshed guard ensures one reload per page, preventing Vercel redeploy-triggered reload loops — no popup, no manual refresh.
  • Activation and old-cache cleanup (SW template): the install event pre-caches cacheList then calls self.skipWaiting(); the activate event iterates caches.keys(), deletes old caches with the 17lai-cache- prefix that don’t match the current cache key, re-runs addAll, then calls self.clients.claim() to take over all pages.
  • Minified backup: in release mode the uncompressed sw.js is backed up to userConfig/sw.js; after the build, the minified version is backed up to userConfig/sw.min.js. Continue mode reuses sw.min.js to keep minified artifacts consistent (falls back to the template version if missing).

10.3 All tunable keys

Key / fileTypeDefaultAllowed values / rangeEffect
pwa.enablebooltruetrue / falseRegister the SW and manifest
userConfig/sw.tmp.jstemplate——SW source (CI injects the version then outputs source/sw.js)
{uniqueIdentifier}placeholderbuild timestampYYYYMMDDHHMMSSCache key, changes every build
{cdnUrl} / {cdnPathVersion} / {cdnPathLatest} / {urlVersion}placeholderinjected by CI—Asset addresses inside the SW
userConfig/sw.min.jsfile——Minified artifact reused in continue mode

10.4 Boundaries & conflicts

  • SW caching is the most common cause of “changes don’t apply”: localhost skips 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 generate locally), {cdnUrl} etc. stay as literals in sw.js, causing cache requests to 404.
  • Skipping registration on localhost is 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 av layout had no practical use and has been removed
from the theme (themes/matery/layout/av.ejs deleted; 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 av

source/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).

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 text

contact page (layout: contact — ⚠️ not implemented in the active theme, do not use)

Note: contact.ejs does not exist in the active theme themes/matery/layout/ (only the disabled upstream reference theme has it), so layout: contact will 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 contact

source/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 valuePageTemplateStatus
av/av/deleted (av.ejs removed)Deprecated (2026-09-12)
movies/movies/themes/matery/layout/movies.ejsAvailable (video address hardcoded)
msg/msg/themes/matery/layout/msg.ejsAvailable
friends/friends/themes/matery/layout/friends.ejsAvailable (data source friends.yml)
contact/contact/does not existNot implemented, do not use
404/404.htmlthemes/matery/layout/404.ejsAvailable
page.toceach standalone page—true / false, disables the TOC
page.comment / page.commentseach standalone page—Enable comments
page.excerpt404 etc.—Page description copy

11.4 Boundaries & conflicts

  • layout: av and layout: contact are 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.
  • movies content 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 spelling friend-card will 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 / comment only work for layouts that support the injection points.

11.5 Summary

  • Four and a half are currently usable: movies, msg, friends, 404 (av deleted, contact not implemented).
  • Only friends has 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-matter layout + (if needed) a data file.

Appendix: Layout Feature Quick Reference

FeatureLocationConfigDescription
Prev/next navpost bottomtheme post.prev_nextadjacent posts by date
Copyrightpost bottomtheme post.copyright (with license sub-key)per-post override via front-matter reprintPolicy
Outdated noticepost toptheme post.outdateoff by default, graded by days
TOCpost sidebartheme tocper-post off via front-matter toc: false
Ad slotssidebartheme post.advertisementsarray of cards, individually toggleable
Category radar/categories/auto-renderedno config
Tag cloud/word cloud/tags/auto-renderedno config
Archive timeline/archives/auto-renderedno config
About charts/about/auto-renderedno config
Responsive breakpointsglobal$breakpoint-* variables in base.styl368/768/992/1200/1400
Galleries/galleries/source/_data/galleries.ymlpages via hexo new gallery
Searchnavbartheme search (algolia/local/pagefind)three engines independently toggleable
Commentsposts/message pages etc.theme walinefront-matter comments toggles
Dark modeglobaltheme dark_modeauto follows system + time window
Encryptionpost pagesroot encrypttag-based or front-matter password
RSS/Sitemaproot pathsroot feed / sitemap / baidusitemapthree feeds + two sitemaps
PWAglobaltheme pwa + userConfig/sw.tmp.jsoffline cache + installable
Standalone pages/movies/ /msg/ /friends/ /404create page under source/ + front-matter layoutfour dedicated templates, see §11 (/av/ removed, /contact/ template not implemented)
Comments
Data Loading...