Loading...

Loading...

This article is both a complete tutorial for matery theme content tag plugins and an automated test sandbox.
The theme’s natively registered tags live in themes/matery/scripts/tags/ (unified registration in index.js).
Automated tests assert the rendered markers noted below.


1. Note

Purpose: colored callout blocks inside a post — reminders, warnings, success feedback, supplementary notes.

Learning path: minimal example → six colors → hide icon → collapsible → nested components → full parameters → boundaries & pitfalls

1.1 Minimal example

Effect (actual rendering on the page):

这是一条最简提示。结构就是:开始标签 + 内容 + 结束标签。

Corresponding source:

{% note %}
这是一条最简提示。结构就是:开始标签 + 内容 + 结束标签。
{% endnote %}

With no color keyword you get a plain block with a grey border.

1.2 Six colors

Effect:

default — 普通提示

primary — 重点强调

info — 补充说明

success — 操作成功

warning — 注意事项

danger — 严重警告

Corresponding source:

{% note default %}**default** — 普通提示{% endnote %}
{% note primary %}**primary** — 重点强调{% endnote %}
{% note info %}**info** — 补充说明{% endnote %}
{% note success %}**success** — 操作成功{% endnote %}
{% note warning %}**warning** — 注意事项{% endnote %}
{% note danger %}**danger** — 严重警告{% endnote %}

Color reference table:

KeywordIcon (Font Awesome code)SemanticsBackground source
defaultf0a9 (right arrow)Plain hint--text-color 8% mix
primaryf055 (plus)Key emphasis--tagsP-purple-color 12%
infof05a (info)Supplementary note--info 8%
successf058 (check)Operation succeeded--success 8%
warningf06a (exclamation)Caution--warning 8%
dangerf056 (cross)Serious warning--danger 8%

Backgrounds are mixed with the card background via color-mix(), so light and dark modes adapt automatically — no separate dark palette needed.

1.3 Hide the icon (no-icon)

Effect:

没有左侧图标,但保留警告色边框。

Corresponding source:

{% note warning no-icon %}没有左侧图标,但保留警告色边框。{% endnote %}

Position is interchangeable (both are keywords, order does not matter):

{% note no-icon warning %}与上一例完全等价{% endnote %}
{% note danger no-icon %}与上一例完全等价{% endnote %}

1.4 Collapsible (details)

Write a title after the keyword and you get a collapsible block (<details><summary>):

Effect:

点击展开:静态站为什么够用

静态站没有服务端,但用 构建时快照 可以获得大部分动态能力。

代价

  • 内容更新需重新构建
  • 搜索是本地索引,不是全文检索服务

Corresponding source:

{% note info 点击展开:静态站为什么够用 %}
静态站没有服务端,但用 **构建时快照** 可以获得大部分动态能力。

### 代价
- 内容更新需重新构建
- 搜索是本地索引,不是全文检索服务
{% endnote %}

Both the title and the body go through Markdown rendering — the title can be bold, the body can hold lists, code and sub-headings.

1.5 Nesting other components

The body is rendered as Markdown, so any tag can be nested inside:

Effect:

组合示例

这一块内部放了 标签 和 粗体,还有代码 console.log(1)。

二级便签

便签可以嵌套便签,内层用内层的颜色。

Corresponding source:

{% note success 组合示例 %}
这一块内部放了 {% label primary@标签 %} 和 **粗体**,还有代码 `console.log(1)`。

{% note warning 二级便签 %}
便签可以嵌套便签,内层用内层的颜色。
{% endnote %}
{% endnote %}

1.6 Full parameters

Arguments are split on spaces. At most the first 2 keywords become CSS classes; all remaining arguments are joined into the collapsible title.

PositionParameterRequiredDefaultDescription
1Color keyword❌nonedefault / primary / info / success / warning / danger
2no-icon❌noneHides the left icon; interchangeable with the color position
2+Collapse title❌noneEvery non-keyword argument is merged into <summary>, rendered as Markdown
ContentBody❌emptyRendered as Markdown, other tags may be nested

All allowed values:

KeywordTypeDescription
defaultColorGrey
primaryColorPurple
infoColorBlue
successColorGreen
warningColorOrange
dangerColorRed
no-iconModifierNot a color, only hides the icon

Alias: subnote and note register the same function — behaviour and styling are identical (it is not “secondary”).

1.7 Boundaries & pitfalls

CaseBehaviour
First word is not a keyword (e.g. 提示内容)No color class is added; that word becomes the collapse title → you get a colorless collapsible block, not a plain block
Three color keywords writtenOnly the first 2 are taken → class="note info success", the third becomes the collapse title
Color misspelled (Warning with a capital)Case-sensitive → treated as a non-keyword, becomes the title and has no color
Empty contentEmits an empty div, no error
Closing tag forgottenThe build reports unclosed tag
Wanted a plain block but wrote a titleImpossible — any non-keyword argument collapses the block. Move the text into the body
Mixed with the ::: containerDifferent output: the tag emits <div class="note primary">, the container emits <div class="note"> (CSS distinguishes them with attribute selectors)

1.8 Summary

  • Most used: note info / note warning — two or three words is enough
  • Want it collapsible: write the title right after the color
  • Want a solid block without an icon: add no-icon
  • Want nesting: keep writing tags in the body (remember to close them in pairs)

2. Timeline

Purpose: show version history, project milestones and personal growth in chronological order — a vertical line plus dots stringing together dated nodes.

Learning path: minimal example → colors and no title → full parameters → advanced → boundaries & pitfalls

2.1 Minimal example

One title plus one node is a complete timeline.

Effect (actual rendering on the page):

里程碑

2026-08

  • 新增内容 tag 测试页

Corresponding source:

{% timeline 里程碑,green %}
<!-- timeline 2026-08 -->
- 新增内容 tag 测试页
<!-- endtimeline -->
{% endtimeline %}

2.2 Common variants

Variant 1: no headline (give no arguments at all; note that you must not write only a title, or it renders class="timeline undefined")

Effect:

2026-07

  • 只有节点,没有整体标题

Corresponding source:

{% timeline %}
<!-- timeline 2026-07 -->
- 只有节点,没有整体标题
<!-- endtimeline -->
{% endtimeline %}

Variant 2: change the color (blue / pink / red / purple / orange / green)

Effect:

蓝色主题

2026-01

  • 蓝

红色主题

2026-02

  • 红

Corresponding source:

{% timeline 蓝色主题,blue %}
<!-- timeline 2026-01 -->
- 蓝
<!-- endtimeline -->
{% endtimeline %}

{% timeline 红色主题,red %}
<!-- timeline 2026-02 -->
- 红
<!-- endtimeline -->
{% endtimeline %}

2.3 Full parameters

Arguments are space-joined first, then split(','), so there are only two positional parameters.

PositionParameterRequiredDefaultDescription
1Title❌noneOverall headline, rendered as Markdown; omitted = no headline
2Color❌nonePasted straight into the class name (not validated)
Sub-block<!-- timeline title --> … <!-- endtimeline -->❌—One event node; title and body both go through Markdown

All allowed values (6 colors)

ColorLine / dot color
blueBlue
pinkPink
redRed
purplePurple
orangeOrange
greenGreen
omittedUses the .timeline default color (no color class appended)

2.4 Advanced: Markdown and other tags inside a node

Node titles and bodies both go through Markdown rendering, so bold, links and even {% label %} work.

Effect:

主题功能演进记录

2026-08

  • 新增内容 tag 测试页(note/timeline/tabs/label 等完整教程)
  • 相册数据重构(galleries.yml 三种形式)
  • 统一 lightGallery 图像查看库 新增

2026-07

  • 评论区架构优化(comment: waline) 优化
  • 修复 href=/ MIME 样式错误 修复

2020

  • 创建博客,开始 matery 深度定制

Corresponding source:

{% timeline 主题功能演进记录,green %}
<!-- timeline 2026-08 -->
- 新增内容 tag 测试页(note/timeline/tabs/label 等完整教程)
- 相册数据重构(galleries.yml 三种形式)
- 统一 lightGallery 图像查看库 {% label success@新增 %}
<!-- endtimeline -->
<!-- timeline 2026-07 -->
- 评论区架构优化(comment: waline) {% label info@优化 %}
- 修复 href=/ MIME 样式错误 {% label warning@修复 %}
<!-- endtimeline -->
<!-- timeline 2020 -->
- 创建博客,开始 matery 深度定制
<!-- endtimeline -->
{% endtimeline %}

2.5 Boundaries & pitfalls

CaseBehaviour
Title only, no colorEmits class="timeline undefined" → no matching class, falls back to the default color (always write the color)
Misspelled color (e.g. grey)Class name written as-is with no CSS → falls back to the default color, no error
<!--timeline 标题--> (no space after timeline)Regex does not match → that node and its content vanish entirely
No newline after -->The opening tag requires -->\n; no match → same as above
Title contains a commaTruncated by split(','); everything after the comma is lost
No arguments at allNo headline, empty color class, only child nodes render
No <!-- timeline --> sub-block at allOnly the headline renders (or an empty container)
Two-word color (light blue)Split on the space, only the first word kept, the rest discarded

2.6 Summary

  • Most used: {% timeline 标题,颜色 %} plus several <!-- timeline 日期 --> … <!-- endtimeline -->
  • No headline wanted: write no arguments at all (a title alone yields an undefined class)
  • Change the theme color: put the color name in the 2nd argument; a typo does not error, it only falls back
  • What a node can hold: all of Markdown, including inline tags like label / button

Test assertion: the page contains the timeline marker + 3 time nodes.


3. Tabs

Purpose: put several pieces of content in one area and switch by clicking a title — good for comparisons, step sequences and parallel options.

Learning path: minimal example → active index / icons → full parameters → advanced → boundaries & pitfalls

3.1 Minimal example

Two tabs, the first one active by default.

Effect (actual rendering on the page):

这里是第一个标签的内容。

Corresponding source:

{% tabs 最小示例组,1 %}
<!-- tab 第一个 -->
这里是第一个标签的内容。
<!-- endtab -->
<!-- tab 第二个 -->
这里是第二个标签的内容。
<!-- endtab -->
{% endtabs %}

3.2 Common variants

Variant 1: activate the second tab (the 2nd argument is 1-based)

Effect:

打开时不是它。

Corresponding source:

{% tabs 激活第二项,2 %}
<!-- tab 第一个 -->
打开时不是它。
<!-- endtab -->
<!-- tab 第二个 -->
打开时默认显示这一页。
<!-- endtab %}
{% endtabs %}

Variant 2: add icons to titles (title @type:icon-name)

Effect:

  • 功能全面
  • 配置灵活
  • 配置项多,有学习成本

Corresponding source:

{% tabs 带图标,1 %}
<!-- tab 优点 @fas:star -->
- 功能全面
- 配置灵活
<!-- endtab -->
<!-- tab 缺点 @fas:exclamation-triangle -->
- 配置项多,有学习成本
<!-- endtab -->
<!-- tab 关于 @fab:github -->
- 源码在 GitHub
<!-- endtab -->
{% endtabs %}

3.3 Full parameters

PositionParameterRequiredDefaultDescription
1Group name✅—Generates the container DOM id (lowercased, spaces → -); must be globally unique on the page
2Active index❌0 (= first active)1-based; 0 or omitted = first active; out of range = none active
Sub-block<!-- tab title @type:icon-name --> … <!-- endtab -->❌auto-namedOne tab; a space is required after tab
ContentTab body❌emptyRendered as Markdown, inline tags may be nested

Icon prefix (type:icon-name after @)

FormActual class
fas:home / solid:homefas fa-home
far:home / regular:homefar fa-home
fal:home / light:homefal fa-home
fad:home / duotone:homefad fa-home
fab:githubfab fa-github
Unknown type (e.g. xxx:home)Falls back to far
No iconNo <i> emitted

3.4 Advanced: a tab body carrying full Markdown blocks

Effect:

  • 功能全面:内容 tag 覆盖 10+ 插件
  • 配置灵活:每个功能可独立开关
  • 性能优化:懒加载 + 占位防 CLS
// 内容里照样能放代码块
const tag = 'tabs'
  • 配置项多,上手有学习成本
  • 部分功能依赖外部 CDN
  • 技术博客:代码 / 教程 / 对比
  • 个人博客:相册 / 项目 / 历程

Corresponding source:

{% tabs 主题功能对比,1 %}
<!-- tab 优点 -->
- 功能全面:内容 tag 覆盖 10+ 插件
- 配置灵活:每个功能可独立开关
- 性能优化:懒加载 + 占位防 CLS

```js
// 内容里照样能放代码块
const tag = 'tabs'
```
<!-- endtab -->
<!-- tab 缺点 -->
- 配置项多,上手有学习成本
- 部分功能依赖外部 CDN
<!-- endtab -->
<!-- tab 适用场景 -->
- 技术博客:代码 / 教程 / 对比
- 个人博客:相册 / 项目 / 历程
<!-- endtab -->
{% endtabs %}

3.5 Boundaries & pitfalls

CaseBehaviour
Missing group namelog.error("[Tabs] Missing required tab name") → returns an empty string, the whole block disappears
Two groups with the same name on one pageDOM id conflict; clicking one also switches the other
Active index > tab count (or negative)No tab carries active → blank first screen
Active index written as 0Equivalent to omitting it (first tab active)
<!--tab 标题--> (no space after tab)Regex does not match → that tab and its content are lost
Title and icon both emptyAutomatically uses “group name + index” as the title
Group name contains Chinese / special charactersid kept as-is (valid HTML5; CSS selectors need escaping)
Config tag_tabs.cdn / tag_tabs.layoutcdn defaults to https://fastly.jsdelivr.net/npm/; layout defaults to ['post','page'] and is not actually read by the current render path (kept for compatibility only)

3.6 Summary

  • Most used: {% tabs 组名 %} with several <!-- tab 标题 --> … <!-- endtab --> inside
  • Open tab N by default: put N in the 2nd argument (1-based; 0/omitted both mean the first)
  • Add an icon: append @fas:star to the title (type:name)
  • The group name must be unique page-wide, otherwise clicking switches across groups

Test assertion: the page contains the nav-tabs marker + 3 tabs.


4. Inline label

Purpose: small colored chips inside prose — tag keywords, statuses and categories without breaking the rhythm of the sentence.

Learning path: minimal example → six colors → full parameters → advanced → boundaries & pitfalls

4.1 Minimal example

Effect (actual rendering on the page):

主要

Corresponding source:

{% label primary@主要 %}

★ Counter-intuitive argument order: the color comes before @ and the text after it (source: split('@'), classes=args[0], text=args[1]).

4.2 Common variants: six colors

Effect:

默认 主要 成功 信息 警告 危险

Corresponding source:

{% label default@默认 %} {% label primary@主要 %} {% label success@成功 %} {% label info@信息 %} {% label warning@警告 %} {% label danger@危险 %}

4.3 Full parameters

PositionParameterRequiredDefaultDescription
1Type❌defaultOne of 6 semantic colors, becomes the label-<type> class name
2Text✅emptyLabel text; when empty it logs log.warn and emits an empty label

All allowed values (6 colors)

TypeSemantics
defaultDefault grey
primaryPrimary (purple / theme color)
successSuccess (green)
infoInfo (blue)
warningWarning (orange)
dangerDanger (red)

4.4 Advanced: embedding in a sentence to express status

Effect:

部署状态:已发布 灰度状态:待观察 回滚状态:已下线 —— 标签与文字混排时不换行、不破坏行高。

Corresponding source:

部署状态:{% label success@已发布 %} 灰度状态:{% label warning@待观察 %} 回滚状态:{% label danger@已下线 %} —— 标签与文字混排时不换行、不破坏行高。

4.5 Boundaries & pitfalls

CaseBehaviour
Type only, no textlog.warn("Label text must be defined!") → emits an empty <span>
No @ at allThe whole string becomes the type and the text is empty → empty label + warn
Text contains @Only the content between the first and second @ is kept, the rest is dropped
Type misspelled / written in Chinese (e.g. 成功)Class name written as-is (label-成功), no CSS match → no styling
Text contains Markdown (**粗**)Not rendered, the asterisks show literally
Text contains HTMLInserted as-is (source does not escape); inline tags like <b> work
Several labels on one lineSeparate with spaces, each independent

4.6 Summary

  • Most used: {% label success@完成 %}
  • Remember the order: color @ text (writing text@color yields an unstyled label)
  • Multiple colors side by side: write several on one line, separated by spaces
  • Do not expect Markdown: text is emitted as-is; for bold, write <b> yourself

Test assertion: the page contains the class="label marker (6 colors).


5. Button

Purpose: an action entry inside a post — jump, download, guide the reader to the next step.

Learning path: minimal example → four forms → full parameters → advanced → boundaries & pitfalls

5.1 Minimal example

Effect (actual rendering on the page):

返回首页

Corresponding source:

{% button /,返回首页,home,首页 %}

★ The link is the first argument (source: url=args[0], text=args[1]); write them in the wrong order and the button points at the text.

5.2 Common variants

Effect:

访问GitHub 关于我 纯文字按钮 Hexo

Corresponding source:

{% button https://github.com/appotry,访问GitHub,github,GitHub %}
{% btn /about,关于我,user-circle,关于 %}
{% button /tags,纯文字按钮,,标签 %}
{% button https://hexo.io,Hexo,fa fa-book,官网 %}

The four variants are: a standard button with an icon, the btn alias, a text-only button (icon left empty), and an icon written as a full fa fa-xxx class name.

5.3 Full parameters

PositionParameterRequiredDefaultDescription
1Link✅emptyURL / relative path; when empty it warns but still emits href=""
2Text❌emptyButton label, Markdown is not rendered
3Icon❌emptyFA class name; fa fa- is prepended when it does not start with fa
4title❌emptyHover tooltip; the attribute is omitted when empty
5+—❌—Silently ignored

Alias: {% btn %} and {% button %} register the same function and are fully equivalent.

5.4 Advanced: putting a button inside a note as a guide

Effect:

下一步

读完这篇建议继续看布局篇,或者直接去标签页找同类文章:

内容 tag 篇按标签浏览

Corresponding source:

{% note info 下一步 %}
读完这篇建议继续看布局篇,或者直接去标签页找同类文章:

{% button /posts/8a11fe0a/,内容 tag 篇,file-text,当前页 %}
{% button /tags,按标签浏览,tags,标签云 %}
{% endnote %}

5.5 Boundaries & pitfalls

CaseBehaviour
Any argument contains a commajoin(' ') then split(',') → arguments get cut apart and everything after shifts
Icon written as homeEmits <i class="fa fa-home">
Icon written as fas fa-home / fa-homeStarts with fa → kept as-is (no duplicate prefix)
Missing linklog.warn("URL can NOT be empty.") → still renders <a href=""> (clicking returns to the current page)
5th argument and beyondSilently dropped
Empty titleNo title="" attribute emitted
Text empty but icon givenAn icon-only button (icon-only buttons work)
Alias btnFully equivalent to button (registered by the same function)

5.6 Summary

  • Most used: {% button 链接,文字,图标,title %}
  • Remember the order: link first, text second (reversed and it jumps to the wrong place)
  • Text-only button: leave the icon slot empty but keep the comma
  • No commas in arguments: any comma shifts the following arguments out of place

Test assertion: the page contains the btn marker (≥4 buttons).


6. GitHub card

Purpose: turn a repository into a clickable card (stars / forks / description) — more convincing than a bare link.

Learning path: minimal example → user card and sizes → full parameters → advanced → boundaries & pitfalls

6.1 Minimal example

Effect (actual rendering on the page):

Corresponding source:

{% githubCard user:appotry repo:hexo %}

Arguments are key:value (colon), space-separated — writing width=300 gets the whole thing ignored.

6.2 Common variants

Variant 1: only user (renders a user card, repo area empty)

Effect:

Corresponding source:

{% githubCard user:hexojs repo:hexo %}

Variant 2: explicit size

Effect:

Corresponding source:

{% githubCard user:appotry repo:hexo-theme-matery width:400 height:140 %}

6.3 Full parameters

PositionParameterRequiredDefaultDescription
anyuser:name✅—GitHub username; a red error block is emitted when missing
anyrepo:repo❌—Repository name; omitted = user card
anywidth:300 / width:300px❌component defaultTrailing px is stripped automatically
anyheight:150 / height:150px❌component defaultSame as above
anytheme:theme❌defaultThe attribute is not emitted when the value is default
anytarget:target❌blankThe attribute is not emitted when the value is blank
anyclient_id:xxx❌—OAuth client_id, raises the API rate limit
anyclient_secret:xxx❌—Not supported (it would leak into the front-end HTML; deliberately not implemented)

6.4 Advanced: two repositories side by side

Effect:

Corresponding source:

{% githubCard user:appotry repo:hexo %}

{% githubCard user:hexojs repo:hexo %}

The blank Markdown line between the cards makes each one its own block.

6.5 Boundaries & pitfalls

CaseBehaviour
Missing userEmits <div style="color:red">GitHub Card配置错误:缺少user参数</div>, the build does not fail
user without repoRenders a user card (repo area empty)
Value contains a spaceSplit into two tokens; the second has no colon → dropped
Written as width=300 (equals sign)No colon found → the argument is ignored
theme:default / target:blankAttribute not emitted, component defaults apply
JavaScript disabled on the page<noscript> shows “JavaScript is required to load GitHub Cards”
Before the card loadsThe container reserves min-height: 150px to prevent layout shift
Same argument written twiceThe later one wins (stored in an object keyed by name)

6.6 Summary

  • Most used: {% githubCard user:xxx repo:yyy %}
  • User card only: leave out repo
  • Change the size: width:400 height:140 (px optional)
  • Raise the API limit: add client_id; never write client_secret

Test assertion: the page contains a github-card or repo-name link marker.


7. Mermaid diagrams

Purpose: draw flows, sequences and class relationships as diagrams — described in text, rendered to SVG at build time.

Learning path: minimal example → three common diagrams → full parameters → advanced → boundaries & pitfalls

⚠️ Precondition: the post front-matter must have mermaid: true, and the theme needs post.mermaid.enable: true. Without the front-matter the whole script is not emitted and the diagram is silently blank (this article declares it).

7.1 Minimal example

Effect (actual rendering on the page):


graph TD
    A --> B

Corresponding source:

{% mermaid %}
graph TD
    A --> B
{% endmermaid %}

7.2 Common variants: the three most used diagrams

Variant 1: flowchart

Effect:


graph TD
    A[构建] --> B{测试}
    B -->|通过| C[部署]
    B -->|失败| D[修复]
    D --> B
    C --> E[监控]

Corresponding source:

{% mermaid %}
graph TD
    A[构建] --> B{测试}
    B -->|通过| C[部署]
    B -->|失败| D[修复]
    D --> B
    C --> E[监控]
{% endmermaid %}

Variant 2: sequence diagram

Effect:


sequenceDiagram
    participant U as 用户
    participant S as 服务器
    participant D as 数据库
    U->>S: 发起请求
    S->>D: 查询数据
    D-->>S: 返回结果
    S-->>U: 响应页面

Corresponding source:

{% mermaid %}
sequenceDiagram
    participant U as 用户
    participant S as 服务器
    participant D as 数据库
    U->>S: 发起请求
    S->>D: 查询数据
    D-->>S: 返回结果
    S-->>U: 响应页面
{% endmermaid %}

Variant 3: class diagram

Effect:


classDiagram
    class 用户 {
        +String 姓名
        +登录()
    }
    class 博客 {
        +String 标题
        +发布()
    }
    用户 --> 博客

Corresponding source:

{% mermaid %}
classDiagram
    class 用户 {
        +String 姓名
        +登录()
    }
    class 博客 {
        +String 标题
        +发布()
    }
    用户 --> 博客
{% endmermaid %}

7.3 Full parameters

Tag arguments

PositionParameterRequiredDefaultDescription
anyAny text❌emptyNot Mermaid config — pasted verbatim into the HTML attribute slot of <code class="mermaid" …>

In other words, theme=dark merely adds an HTML attribute to <code> and does not change the diagram theme; the theme comes from post.mermaid.options.theme below.

Config keys (theme _config.yml post.mermaid)

KeyAllowed valuesDefaultDescription
enabletrue / false—Master switch
specifictrue / falsetrueWhen true, only posts with mermaid: true get the script
options.themedefault / forest / dark / neutral / basedefaultDiagram theme
options.startOnLoadtrue / falsefalseThe theme controls render timing itself; do not set it to true
options.securityLevelstrict / loose / antiscript / sandboxlooseHow much HTML is allowed through
options.flowchart.useMaxWidthtrue / falsetrueWhether flowcharts fill the container

Supported diagram types: graph / flowchart, sequenceDiagram, classDiagram, stateDiagram-v2, gantt, pie, erDiagram, gitGraph, journey, mindmap, timeline, quadrantChart.

7.4 Advanced: pie chart (stable output, good for proportions)

Effect:


pie title 内容类型占比
    "教程" : 45
    "排障" : 30
    "随笔" : 25

Corresponding source:

{% mermaid %}
pie title 内容类型占比
    "教程" : 45
    "排障" : 30
    "随笔" : 25
{% endmermaid %}

7.5 Boundaries & pitfalls

CaseBehaviour
specific: true but front-matter lacks mermaid: trueThe theme emits no script at all → blank diagram, no console error (the most invisible pitfall)
theme=dark inside the tagOnly adds an HTML attribute, the diagram theme does not change
Diagram syntax error (indentation / arrow)Mermaid throws a parse error; the container is left empty and shows the error graphic
A mermaid code fence in the body (three backticks)Not auto-rendered (a different front-end plugin path); always use this tag
startOnLoad: trueConflicts with the theme’s own render timing; may double-render / flicker on first paint
Several diagrams on one pageEach renders independently, no interference
Diagrams inside encrypted fragmentsRe-rendered by events.refresh() after decryption (idempotent)
This page’s front-matterAlready sets mermaid: true — the precondition for the examples above to render

7.6 Summary

  • Most used: {% mermaid %} with native Mermaid syntax inside
  • Remember the precondition: front-matter needs mermaid: true (when specific: true)
  • Change the theme: edit post.mermaid.options.theme, not a tag argument
  • No code fences: a three-backtick mermaid block does not render; always use the tag
  • A syntax error does not fail the build: that block is just blank — check the console for a parse error

Test assertion: the page contains the class="mermaid" marker (≥3 diagrams).


8. PDF embed

Purpose: page through a PDF right inside the post — manuals, drawings and reports without leaving the page.

Learning path: minimal example → full parameters → advanced → boundaries & pitfalls

8.1 Minimal example

Effect (actual rendering on the page):

Corresponding source:

{% pdf /doc/Linux学习笔记.pdf %}

8.2 Full parameters

PositionParameterRequiredDefaultDescription
1URL✅—PDF address; there are no other parameters such as width/height

Automatic type detection (matched in order, first hit wins)

OrderURL traitTypeRender method
1contains .pdfnormal<embed>, 550px tall
2contains drive.google.comgoogledoc<iframe>, 550px tall
3contains www.slideshare.netslideshare<iframe>, 550px tall
4anything elsenormal<embed>

8.3 Advanced: a note in front (note + PDF combination)

Effect:

移动端提示

手机浏览器大多不支持内联 PDF,会退化成下载或空白 —— 桌面端体验完整。

Corresponding source:

{% note warning 移动端提示 %}
手机浏览器大多不支持内联 PDF,会退化成下载或空白 —— 桌面端体验完整。
{% endnote %}

{% pdf /doc/Linux学习笔记.pdf %}

8.4 Boundaries & pitfalls

CaseBehaviour
Google Drive direct link (URL contains .pdf)Matches rule 1 first → embedded as normal, not via the Google preview
drive.google.com/viewer?url=xxx.pdfAlso contains .pdf → classified as normal
A slideshare link containing .pdfClassified as normal
Want a different heightNo parameter for it; 550px is hardcoded in 3 places, so you must edit the source or override with extra CSS
Empty argumentEmits <embed src="">, an empty container
Relative pathResolved against the site root (e.g. /medias_webp/docs/sample.pdf)
Mobile browsersMost do not support inline PDF → blank or a download prompt (not a tag issue)

8.5 Summary

  • Most used: {% pdf /path/file.pdf %}
  • Remember the limit: one argument only, height hardcoded to 550px
  • Want the Google preview: the URL must not contain .pdf, otherwise it is treated as a plain embed
  • In-site files: write the path starting from the site root

Test assertion: the page contains a PDF-related container marker.


9. Insert fragment (insertmd)

Purpose: insert Markdown fragments from source/_template/ into the body — maintain once, reuse everywhere (series index, disclaimer, ad slot).

Learning path: minimal example → with separator → full parameters → boundaries & pitfalls

9.1 Minimal example

Effect (actual rendering on the page):

系列教程

全部文章RSS订阅

Corresponding source:

{% insertmd '_template/系列教程.md' %}

9.2 Common variants: adding a separator

The 2nd argument is Markdown separator content, appended after every file (including the last one).

Effect:

系列教程

全部文章RSS订阅


Corresponding source:

{% insertmd '_template/系列教程.md' '---' %}

9.3 Full parameters

PositionParameterRequiredDefaultDescription
1Path✅—Relative to source/ (not to the current post); a file or a directory both work
2Separator❌emptyAppended after the Markdown rendering of every file (including the last)

Behaviour details

ItemDescription
Directory modePassing a directory recursively collects every .md (other extensions ignored) and inserts the whole directory at once
OrderinglocaleCompare on the full path → 第10篇 sorts before 第2篇 (lexicographic)
SeparatorAppended once after each file, so there is also one trailing at the end
RendererAuto-detects markdown-it / marked; renders with disableNunjucks: true → Hexo tag syntax inside fragments is not executed
Registration{ async: true, ends: false, priority: 2 }
Dependencyfs-extra

9.4 Boundaries & pitfalls

CaseBehaviour
Path does not existlog.error + returns an empty string → the page silently misses content, the build does not fail
Path written relative to the post (../)The resolution base is source/, so it is not found (silently empty)
Separator contains spacesMust be quoted, otherwise only the first two segments are taken
Very deep directory / too many filesNo depth limit; a large directory noticeably slows the build
Tags embedded in a fragmentNot executed (disableNunjucks), rendered as plain Markdown only
One file fails to renderThat file returns an empty string, the others continue

9.5 Summary

  • Most used: {% insertmd '_template/xxx.md' %} (path relative to source/)
  • Want a divider: put '---' in the 2nd argument
  • Want bulk insertion: pass a directory, merged in path lexicographic order
  • No tags inside fragments: under disableNunjucks they are not executed, only plain text

Test assertion: the rendered output contains the template fragment content.


10. WeChat dialog card

Purpose: turn Q&A, support conversations and troubleshooting sessions into a chat screenshot — more direct than a blockquote.

Learning path: minimal example → multi-turn with Markdown → full parameters → advanced → boundaries & pitfalls

10.1 Minimal example

Effect (actual rendering on the page):

User

你好

Assistant

你好,有什么可以帮您?

Corresponding source:

{% wechat_dialog %}
User: 你好
Assistant: 你好,有什么可以帮您?
{% endwechat_dialog %}

★ It must be User: / Assistant: line format, not inline arguments — writing {% wd 文字,发送者 %} renders incorrectly.

10.2 Common variants: multiple turns with Markdown

Effect:

User

你好,我想了解 matery 主题

Assistant

好的,有什么可以帮您?

User

主题支持哪些功能?

Assistant

内容 tag、相册、搜索、评论等 20+ 功能

Assistant

常用清单:

  • 内容 tag(note / tabs / timeline)
  • 相册与图库
  • 本地搜索 + Pagefind

Corresponding source:

{% wechat_dialog %}
User: 你好,我想了解 matery 主题
Assistant: 好的,有什么可以帮您?
User: 主题支持哪些功能?
Assistant: 内容 tag、相册、搜索、评论等 **20+** 功能
Assistant: 常用清单:
- 内容 tag(note / tabs / timeline)
- 相册与图库
- 本地搜索 + Pagefind
{% endwechat_dialog %}

10.3 Full parameters

PositionParameterRequiredDefaultDescription
—none——Takes no positional arguments; anything written is ignored. All content comes from the role lines inside the block

Rules inside the block

FormBehaviour
Starts with User:New message: right side, green bubble, avatar 2.jpg
Starts with Assistant:New message: left side, grey bubble, avatar 1.jpg
Any other lineAppended to the current message (line breaks preserved)
Message bodyRendered with a dedicated new MarkdownIt() (bypasses the Hexo renderer)

10.4 Advanced: the wd alias for a troubleshooting dialog

Effect:

User

改了样式为什么不生效?

Assistant

先确认是不是缓存:主题配置改动必须重新 clean 构建。

User

clean 了还是不变

Assistant

那看两点:

  1. 配置改的是 userConfig/_config.tmp.yml 还是构建产物 themes/matery/_config.yml
  2. 容器里 pm2 restart 不够,db.json 缓存还在

Corresponding source:

{% wd %}
User: 改了样式为什么不生效?
Assistant: 先确认是不是缓存:**主题配置改动必须重新 clean 构建**。
User: clean 了还是不变
Assistant: 那看两点:
1. 配置改的是 `userConfig/_config.tmp.yml` 还是构建产物 `themes/matery/_config.yml`
2. 容器里 `pm2 restart` 不够,`db.json` 缓存还在
{% endwd %}

10.5 Boundaries & pitfalls

CaseBehaviour
Chinese colon User:Not recognised (the regex requires an ASCII :) → the whole line is merged into the previous message
Lowercase user: / assistant:Not recognised (case-sensitive) → merged into the previous message
Content before the first role linecurrentRole is empty → emitted as an assistant bubble
No role line at all in the blockAll content is merged into one assistant message
Tags such as {% note %} inside a messageNot effective (they do not go through the Hexo tag pipeline)
AvatarsHardcoded to /medias_webp/avatar/1.jpg, 2.jpg; changing them requires editing the source
Empty blockEmits only an empty .chat-container

10.6 Summary

  • Most used: start each line with User: / Assistant:; other lines join the current message automatically
  • Alias: {% wd %} is fully equivalent
  • Markdown works: bold, lists and inline code all fine
  • Tags do not work: {% note %} and friends inside the block are not executed
  • The colon must be ASCII, and the casing must be exact

Test assertion: the page contains the WeChat dialog container marker (.chat-container).


11. Group image

Purpose: arrange several images in a row/column grid — gallery thumbnails, comparison shots and step screenshots no longer stack one per line.

Learning path: minimal example → default layout → full parameters → advanced → boundaries & pitfalls

11.1 Minimal example

3 images with a 2-1 layout (2 on the first row, 1 on the second).

Effect (actual rendering on the page):

封面1
封面2
封面3

Corresponding source:

{% groupimage 3 2-1 %}
![封面1](https://blog.17lai.site/medias_webp/cover/hexo.webp)
![封面2](https://blog.17lai.site/medias_webp/cover/hexo.webp)
![封面3](https://blog.17lai.site/medias_webp/cover/hexo.webp)
{% endgroupimage %}

11.2 Common variants: omitting the layout

When the 2nd argument is omitted the default layout is chosen from the count (4 images → 2-2).

Effect:

封面1
封面2
封面3
封面4

Corresponding source:

{% groupimage 4 %}
![封面1](https://blog.17lai.site/medias_webp/cover/hexo.webp)
![封面2](https://blog.17lai.site/medias_webp/cover/hexo.webp)
![封面3](https://blog.17lai.site/medias_webp/cover/hexo.webp)
![封面4](https://blog.17lai.site/medias_webp/cover/hexo.webp)
{% endgroupimage %}

11.3 Full parameters

PositionParameterRequiredDefaultDescription
1Total count✅—Parsed with parseInt; determines the layout and per-row quota
2Layout❌see table belowPer-row counts separated by - (3-2 = 3 then 2)
ContentImages✅—Standard ![](); extracted from <img> in the rendered HTML

Default layout (when no layout is given or validation fails)

CountLayoutCountLayout
21-173-2-2
32-183-2-3
42-293-3-3
53-2103-2-2-3
63-3>103 per row

Alias: {% gi %} and {% groupimage %} register the same function and are fully equivalent.

11.4 Advanced: a custom three-row layout

Effect:

封面1
封面2
封面3
封面4
封面5

Corresponding source:

{% gi 5 3-1-1 %}
![封面1](https://blog.17lai.site/medias_webp/cover/hexo.webp)
![封面2](https://blog.17lai.site/medias_webp/cover/hexo.webp)
![封面3](https://blog.17lai.site/medias_webp/cover/hexo.webp)
![封面4](https://blog.17lai.site/medias_webp/cover/hexo.webp)
![封面5](https://blog.17lai.site/medias_webp/cover/hexo.webp)
{% endgi %}

11.5 Boundaries & pitfalls

CaseBehaviour
sum(layout) != countSilently falls back to the default layout (no error, no warning)
Fewer images than the countLater rows get empty arrays → empty rows / whitespace
More images than the countImages beyond the quota are discarded
Count = 1 or > 10 with no layoutFalls back to “3 per row”
Layout written as 3,2 (comma)Only - is used to split, 3,2 parses as 3 → sum mismatch → default layout
Image written as a bare URL / other syntaxNo <img> extracted → that image is not shown (only rendered <img> counts)
Count is not a numberparseInt → NaN → no default layout → 3 per row

11.6 Summary

  • Most used: {% groupimage 数量 布局 %}![图](url)...{% endgroupimage %}
  • Do not want to compute the layout: write only the count and use the default
  • Custom: use - separated segments like 3-2-1; their sum must equal the count, otherwise it silently falls back
  • Images must use Markdown syntax: a bare URL is not extracted

Test assertion: the page contains the group-image container marker.


12. URL card (cardurl)

Purpose: turn a link into a card with title/description — recommending resources or citing official docs looks better than a bare link.

Learning path: minimal example → with icon → full parameters → advanced → boundaries & pitfalls

12.1 Minimal example

Effect (actual rendering on the page):

夜法之书-hexo仓库
个人独立blog源码,基于hexo搭建

Corresponding source:

{% cardurl [url=https://github.com/appotry/hexo] [title=夜法之书-hexo仓库] [desc=个人独立blog源码,基于hexo搭建] %}

Arguments must be wrapped in square brackets ([key=value]). Drop the brackets → the regex does not match → arguments are silently ignored and you get an empty card.

12.2 Common variants: adding a left icon

Effect:

夜法之书
个人独立技术博客

Corresponding source:

{% cardurl [url=https://blog.17lai.site] [title=夜法之书] [desc=个人独立技术博客] [avatar=/medias_webp/avatar/1.jpg] %}

12.3 Full parameters

PositionParameterRequiredDefaultDescription
any[url=...]✅—Target link
any[title=...]❌same as urlCard title
any[desc=...]❌noneDescription text
any[avatar=...]❌noneLeft icon; no <img> emitted when omitted

12.4 Advanced: a card list as a resource directory

Effect:

博客源码
undefined
组件教程
主题全部组件的公开文档

Corresponding source:

{% cardurl [url=https://github.com/appotry/hexo] [title=博客源码] [desc=Hexo 主题与内容全部开源] [avatar=/medias_webp/avatar/1.jpg] %}

{% cardurl [url=https://blog.17lai.site/tutorial/] [title=组件教程] [desc=主题全部组件的公开文档] [avatar=/medias_webp/avatar/2.jpg] %}

12.5 Boundaries & pitfalls

CaseBehaviour
Arguments without square bracketsThe regex \[([^=]+)=(.+)\] does not match → arguments silently ignored, an empty card is emitted
Missing descShows the literal undefined (source does not null-check)
Missing urlhref="undefined", clicking goes to /undefined
Missing titleFalls back to showing url
Value contains HTML/MarkdownFully HTML-escaped (XSS protection) → shown as entities, not rendered
Value contains ]The regex is greedy (.+) → takes everything up to the last ]
Empty value [desc=].+ requires at least 1 character → that argument is ignored
Misspelled key ([titel=...])Unknown keys are ignored

12.6 Summary

  • Most used: {% cardurl [url=...] [title=...] [desc=...] %}
  • Remember the brackets: not one [key=value] can be missing
  • Fill in desc: without desc it shows undefined
  • Add an icon: [avatar=图片URL]
  • Do not put HTML in: everything is escaped and only shows as entities

Test assertion: the page contains the URL card container marker (.card-url-wrapper).


13. Admonition container (markdown-it-container)

Purpose: write callouts with ::: syntax — no Hexo tag involved, parsed purely at the Markdown layer.

Learning path: minimal example → title / five types → full parameters → advanced → boundaries & pitfalls

13.1 Minimal example

Effect (actual rendering on the page):

这是一个 warning 容器——需要注意的内容!

Corresponding source:

::: warning
这是一个 warning 容器——需要注意的内容!
:::

13.2 Common variants

Variant 1: with a title (write the title on the same line after the type)

Effect:

带标题的容器:类型后同一行写标题。

Corresponding source:

::: info 可选标题
带标题的容器:类型后同一行写标题。
:::

Variant 2: five types side by side

Effect:

这是一个 note 容器——补充说明。

这是一个 info 容器——信息提示。

这是一个 attention 容器——注意警示。

这是一个 error 容器——严重错误。

Corresponding source:

::: note
这是一个 note 容器——补充说明。
:::

::: info
这是一个 info 容器——信息提示。
:::

::: attention
这是一个 attention 容器——注意警示。
:::

::: error
这是一个 error 容器——严重错误。
:::

13.3 Full parameters

PositionParameterRequiredDefaultDescription
1Type name✅—Must be one of the 7 registered in the root _config.yml
2Optional title❌noneSame line as the type, rendered as a heading paragraph inside the container
Close:::✅—On its own line; missing it swallows all following content

All allowed values (7 registered names)

NameColor
warningOrange
attentionOrange (same as warning)
noteGreen
infoBlue
tipBlue (same as info)
hintBlue (same as info)
errorRed

Difference from the {% note %} tag

Aspect::: container{% note %} tag
Parse layermarkdown-it plugin (Markdown layer)Hexo tag plugin
Outputbare <div class="warning"> (no note class)<div class="note warning">
Collapsible❌✅ (remaining arguments become the title)
Type extensiononly the 7 registered6 colors + no-icon

13.4 Advanced: lists and code inside a container

Effect:

  1. 先看构建日志有没有报错
  2. 再看浏览器控制台
  3. 最后确认是不是缓存
npm run clean && npm run build

Corresponding source:

::: tip 排查顺序
1. 先看构建日志有没有报错
2. 再看浏览器控制台
3. 最后确认是不是缓存

```bash
npm run clean && npm run build
```
:::

13.5 Boundaries & pitfalls

CaseBehaviour
Unregistered type (::: danger)Not parsed → ::: and the text are emitted verbatim as plain paragraphs
Forgetting the closing :::The entire following section is merged into the container
Nesting containers of the same namemarkdown-it-container does not support direct same-name nesting; separate them with other content
Multi-line titleOnly the first line is recognised as the title, the rest goes into the body
Style scopingRules hang off the .post-container descendant selector → wiki pages need <main> carrying that class (already fixed)
Difference from !!! admon!!! output carries .admonition + a title paragraph and closes on two blank lines

Deprecated: the original {% admonition %} tag form has been removed (the tag plugin no longer exists); callouts are now provided by markdown-it-container (:::) and markdown-it-admon (!!!, see the Markdown Syntax chapter).

13.6 Summary

  • Most used: ::: warning … :::
  • Want a title: write it after the type on the same line
  • Only 7 types; writing danger or similar is emitted verbatim
  • Choose one of {% note %} and :::: use the tag for collapsibility, ::: for pure Markdown
  • Never forget the closing :::, or the rest of the section is swallowed

Test assertion: the page contains the admonition container marker.


14. Encrypt fragment tag ({% encrypt %})

Purpose: password-protect a few paragraphs inside a post — each fragment has its own password, they do not affect each other, and decryption expands in place.

Learning path: minimal example → title and description → full parameters → advanced (composition + whole-wiki encryption) → boundaries & pitfalls

14.1 Minimal example

Effect (actual rendering on the page, password demo123):

您好, 这里需要密码.

Corresponding source:

{% encrypt demo123 %}
这一段在构建产物里是密文,输入密码后才展开。
{% endencrypt %}

14.2 Common variants: prompt title and description

Effect (password test-secret):

私有内容

Corresponding source:

{% encrypt "test-secret" "私有内容" "这是一段测试加密内容" %}
**粗体测试** 和 {% note %}内部 note 标签{% endnote %} 结尾。

SECRET-SEGMENT-TEXT-MARKER
{% endencrypt %}

14.3 Full parameters

PositionParameterRequiredDefaultDescription
1Password✅—Decryption password (Hexo strips the quotes automatically)
2Title❌emptyPrompt shown above the password box
3Description❌emptyPlaceholder text for the password input
ContentBody❌emptyThe encrypted Markdown, may contain internal tags (note/timeline etc.)

14.4 Advanced

Advanced 1: mixed rendering of internal tags and Markdown (secondary render after decryption, after_post_render approach)

Effect (visible after decryption):

组合内容

Corresponding source:

{% encrypt nested-demo "组合内容" "输入 nested-demo 查看" %}
{% note success 解密后生效 %}
片段里可以正常写 `note`、`label`,以及 **Markdown**。
{% endnote %}

{% label success@已解密 %} {% label info@二次渲染 %}
{% endencrypt %}

Advanced 2: whole-wiki encryption (configure once in the sidebar data source and the entire wiki is encrypted)

Effect (description): the wiki page shows a password box on first paint; after decryption the sidebar and body expand together, and other pages of the same wiki decrypt automatically (the derived key is stored in localStorage).

Corresponding source:

# source/_data/docs-sidebar.yml
encrypt_password: "你的密码"    # 必填,整站 wiki 加密
encrypt_message: 本文已加密      # 可选,提示语
encrypt_placeholder: 请输入密码   # 可选,输入框占位

Test assertion: L2y (wiki encrypted page decryption) + L8 8c (encrypted wiki accessible).

14.5 Boundaries & pitfalls

CaseBehaviour
No passwordlog.warn + outputs the plaintext as-is (no encryption at all — the most dangerous case)
Password/title contains spaces or Chinese punctuationMust be quoted; otherwise it is split on spaces and only the first segment becomes the password
Forgetting {% endencrypt %}The build reports an unclosed tag error
Multiple fragments in one postEach has its own password, independent of the others
Storage keyhbe.v4.segment.<page path>#<fragment index> → changing the post path or reordering fragments invalidates the decrypted state (the password is required again)
Forgotten passwordUnrecoverable (AES-GCM + PBKDF2, no backdoor)
Source fileThe source Markdown is still plaintext: a public repo means public content — this feature only protects the rendered output
Components after decryptionCode blocks / lightbox / Mermaid / layout are all re-initialised by hbe-bundle onSuccess

Concrete re-initialisation performed for each component after decryption (these elements do not exist in the DOM before decryption, so they must be re-run):

ComponentRe-initialisation
Code blockscodeWidget() scans the new <pre> elements and builds the toolbar
Image lightboxarticleInit() wraps img → lightGallery
Mermaidevents.refresh() re-renders (idempotent)
LayoutrefreshLayout() re-layouts

14.6 Summary

  • Most used: {% encrypt 密码 %} … {% endencrypt %}
  • Want a prompt: follow with "标题" "输入框占位"; anything with spaces must be quoted
  • Tags can be embedded: note / label inside the fragment render normally after decryption
  • Forgotten password = lost content — do not keep the only copy in your head
  • Whole-wiki encryption: set encrypt_password in docs-sidebar.yml

Encryption unit tests tools/tests/unit/unit-encrypt.test.js + unit/unit-encrypt2.test.js cover: AES-GCM + PBKDF2 round-trip / fragment decryption / internal note rendering / markdown bold / dk storage without password; post-decrypt runtime behaviour is verified by gate layer L2y (decrypt-refresh + container integrity).

Test assertion: L2y (component initialisation after decryption).


15. Math formulas (MathJax / KaTeX dual channel)

Purpose: write LaTeX formulas in the body and have them SSR-rendered to SVG at build time — stable display without front-end JS.

Learning path: inline → block → full parameters (delimiters and engines) → advanced → boundaries & pitfalls

⚠️ Precondition: the post front-matter needs mathjax: true (when specific: true); the theme’s post.math.engine selects the math engine.

15.1 Minimal example: inline formula

Effect (actual rendering on the page): the mass-energy equation E=mc2sits right in the middle of a sentence.

Corresponding source:

The mass-energy equation $E=mc^2$ sits right in the middle of a sentence.

15.2 Common variants: block formula

Effect:

∫0∞e−x2dx=π2

Corresponding source:

$$
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
$$

15.3 Full parameters

Delimiter support (by engine)

Formmathjax enginekatex engine
$...$ inline✅✅
$$...$$ block✅✅
\(...\) inline❌ (hardcoded in 5.x, config has no effect)✅ (must be a standalone block)
\[...\] block❌✅ (must be a standalone block)

Engine comparison

Itemmathjax (default)katex
Build sidemarkdown-it-mathjax3 (Node SSR emits SVG)markdown-it-texmath
Frontendloads MathJax 3.2.2loads KaTeX CSS only (no JS needed)
Output marker<mjx-container>.katex
Switch methodpost.math.engine: mathjax + keep mathjax3post.math.engine: katex + comment out mathjax3, enable texmath

Configuration (root _config.yml + theme _config.yml)

# 根 _config.yml:markdown-it-mathjax3(Node 端 SSR 输出 MathJax SVG)
markdown:
  plugins:
    - name: markdown-it-mathjax3
      options:
        tex:
          inlineMath: [['$', '$']]
          displayMath: [['$$', '$$']]
          processEscapes: true

# 主题 _config.yml:post.math 引擎(Fluid 风格,二选一)
post:
  math:
    enable: false          # 开启后文章默认可用
    specific: true         # true 时需 front-matter `math: true` 才启动
    engine: mathjax        # Options: mathjax | katex

15.4 Advanced: matrices and multi-line derivations

Effect:

A=(abcd),det(A)=ad−bc

Corresponding source:

$$
A = \begin{pmatrix} a & b \\ c & d \end{pmatrix},\quad
\det(A) = ad - bc
$$

15.5 Boundaries & pitfalls

CaseBehaviour
Writing \(...\) with the mathjax engineEmitted verbatim, not rendered (inlineMath config is ineffective in 5.x)
Both engines enabled at onceConflict (both register math_inline); only one may be used
$ meaning money (e.g. $5)Treated as the start of a formula → escape as \$5
Block $$ on the same line as textMust be on its own line, otherwise it may be treated as inline
specific: true but front-matter lacks mathjax: trueThe theme does not inject the front-end script (the template checks page.mathjax, not math)
\[...\] under the katex engineMust be a standalone block; inline mixing does not work
Formulas inside a mind mapGo through KaTeX (hexo_markmap.features includes math)

15.6 Summary

  • Most used: inline $...$, block $$...$$ (both engines support them)
  • Remember the precondition: write mathjax: true in front-matter
  • Escape money: \$5, otherwise it starts a formula
  • Do not mix engines: mathjax and katex are mutually exclusive
  • Formulas inside mind maps: configure hexo_markmap.features: [math]

Test assertion: tools/tests/rich-content-integration.test.js (L2o): formula page mjx-container ≥ 10 + katex ≥ 1 (dual channel).


16. Mind map (markmap)

Purpose: draw an interactive mind map from a Markdown list — zoom, collapse, click links; good for mapping knowledge structures.

Learning path: minimal example → omitting the height → full parameters → advanced → boundaries & pitfalls

16.1 Minimal example

Effect (actual rendering on the page):

Corresponding source:

{% markmap 350px %}
- 主题功能测试系列
  - 交互视觉篇
  - 内容 tag 篇
- 自动化测试
  - L1 构建验证
  - L13 单测门禁
{% endmarkmap %}

16.2 Common variants: no height

Effect:

Corresponding source:

{% markmap %}
- 省略高度参数
  - 走 CSS 默认高度
{% endmarkmap %}

16.3 Full parameters

PositionParameterRequiredDefaultDescription
1Height❌empty (CSS default)Written verbatim into the container style="height: …"; a unit is required (350px)
ContentList✅—Standard Markdown unordered list, indent with 2 spaces per level

Config keys (root _config.yml hexo_markmap)

KeyAllowed valuesDefaultDescription
CDNjsdelivr / custom etc.plugin defaultAsset source; this project uses jsdelivr, then localizes via filters/markmap-localize.js
featuresmath / prism / zoom (array)[]Formulas, code highlighting, zoom toolbar
themeauto etc.plugin defaultMind map theme; auto follows light/dark
hexo_markmap:
  CDN: 'jsdelivr'   # 2026-08-24: fastly.jsdelivr.net 不可达,换 cdn.jsdelivr.net
  features:
    - math          # 脑图内公式(KaTeX)
    - prism         # 代码高亮
    - zoom          # 缩放
  theme: auto

Effect:

Corresponding source:

{% markmap 320px %}
- 进阶节点
  - 链接 [Hexo](https://hexo.io)
  - 行内代码 `npm run build`
  - 公式 $a^2+b^2=c^2$
{% endmarkmap %}

16.5 Boundaries & pitfalls

CaseBehaviour
Height without a unit (350)style="height: 350" is invalid → ignored by the browser, falls back to the CSS default height
Content is not a listOnly a root node or a render error (you must use a - list)
Indentation levels are wrongHierarchy is inferred from indentation; bad indentation attaches nodes to the wrong parent
features missing mathFormulas display as raw LaTeX text
hexo_markmap not configuredUses the plugin default CDN, which may be blocked and render blank
A page containing {% encrypt %}Scripts switch to a serial onload chain (see below); static pages still use defer
Multiple markmaps on one pageIndependent ids, no interference

Coexistence with encrypted fragments (important): markmap’s four scripts (d3 / markmap-view / markmap-toolbar / init) are localized by an after_render:html filter. Pages containing {% encrypt %} use a serial onload-chain loader instead of <script defer> — because the HTML spec says a dynamically inserted <script> ignores defer (its async defaults to true). When the hbe decryption flow re-inserts them, they execute in download-completion order, exactly inverting the dependency chain (init at 1.8KB finishes first → window.markmap undefined; d3 at 280KB finishes last → markmap-view throws d3 is not defined). Static pages keep defer (parallel download, better first paint). Full root cause and debugging lessons: docs/EXPERIENCE.md §58.

16.6 Summary

  • Most used: {% markmap 350px %} + an unordered list
  • The height needs a unit, otherwise it is ignored
  • Hierarchy comes from indentation (2 spaces per level)
  • Want formulas / code highlighting: configure hexo_markmap.features: [math, prism]
  • On the same page as encrypt: the loading chain switches to serial onload, which is expected behaviour

Test assertion: tools/tests/rich-content-integration.test.js (L2o): .markmap svg renders.


17. Douban card

Purpose: embed a Douban entry card for a book / movie / album (cover + rating + metadata). Since 2026-10-19 this is a local implementation built into the theme; covers are downloaded at build time and no third-party image proxy is involved.

Learning path: minimal example → movie and music → full parameters → advanced → boundaries & pitfalls

17.1 Minimal example

Effect (actual rendering on the page):

Corresponding source:

{% douban book 30376420 %}

17.2 Common variants

Variant 1: movie

Effect:

Corresponding source:

{% douban movie 24745500 %}

Variant 2: music

Effect:

Corresponding source:

{% douban music 35099703 %}

17.3 Full parameters

PositionParameterRequiredDefaultDescription
1 / 2type✅—One of book / movie / music
1 / 2id✅—Douban entry id, must match /^\d+$/ (digits only)
—Order——Decided with isNaN: the numeric token is the id, the non-numeric one is the type; order is free

Config keys (root _config.yml doubanCard)

KeyAllowed valuesDefaultDescription
cookieDouban cookie stringemptyUsed when an entry/endpoint requires a logged-in session
localImagestrue / falsetrueWhether covers are downloaded locally; false hits Douban directly (returns 418)
imagePathdirectory pathsource/medias_webp/doubanWhere local covers are written
imageUrlPrefixURL prefix/medias_webp/doubanPrefix used when rendering image URLs

Localization mechanism

ItemDescription
Codethemes/matery/scripts/tags/douban-card.js
Dependenciescheerio + superagent
CacheDoubanCard.json (deduped by url; a hit skips Douban)
CoverDownloaded at build time to source/medias_webp/douban/{type}-{id}.jpg; existing files are skipped
RefererPer-type Douban referer built in (anti-hotlink requirement)
Dark modeOverlay brightness(0.6) → 0.4 in dark; text uses var(--white)

17.4 Advanced: swapping the order of type and id

isNaN decides which token is which, so {% douban 30376420 book %} and {% douban book 30376420 %} are equivalent.

Effect:

Corresponding source:

{% douban 30376420 book %}

17.5 Boundaries & pitfalls

CaseBehaviour
Type misspelled / id not numeric (e.g. 30376420a)Promise.reject → build fails (not a silent skip)
Order swapped ({% douban 30376420 book %})Works the same (isNaN decides which token is the id)
Douban returns 418 (hotlink protection)Downloaded at build time with a per-type Referer, displays normally
localImages: falseReferences the original Douban image directly → 418, blank cover
Cache hitDoes not contact Douban (builds even offline)
Cache fileDoubanCard.json in the project root, deduped by url; delete it to force a refresh
Fetch failureDegrades to a placeholder image + placeholder text (book “见字如晤” / movie “灯影绰约” / music “乐以忘忧”) without blocking the build
Cover file already existsDownload skipped (faster incremental builds)

Background: Douban has tightened hotlink protection; third-party proxies now receive 418 (all covers blank). Localizing covers means one download, usable indefinitely. See docs/EXPERIENCE.md (douban card notes).

17.6 Summary

  • Most used: {% douban book 30376420 %} (type + numeric id)
  • Order is free: the non-numeric token is the type, the numeric one is the id
  • The id must be numeric, otherwise the build fails outright
  • Localize covers: localImages: true (default) — do not turn it off

Appendix: Non-tag theme features

The following three items are not “article-embedded tag plugins” (§1–§17) but standalone theme-level features. They are grouped here to mark the boundary between tag and non-tag features.

18. Typewriter typing (fun_features)

Purpose: the homepage banner subtitle typed out character by character — a touch of ceremony on first paint (same source as subtitle.typed in Interaction & Visual §3, config aggregated under fun_features.typing).

Learning path: minimal example → variant → full parameters → boundaries & pitfalls

18.1 Minimal example

Effect (description): the homepage subtitle types out character by character with a blinking cursor; this article is not the homepage, so see the site homepage for the real effect (it works whenever a .typed-cursor element exists).

Corresponding source:

fun_features:
  typing:
    enable: true      # 打字机开关
    typeSpeed: 70     # 打印速度,数字越大越慢
    cursorChar: "_"   # 光标字符
    loop: false       # 是否循环播放

18.2 Common variants: disable on a single page

Turn the typewriter off for this page in the post front-matter; other pages are unaffected.

Effect (description): the subtitle on that page is shown statically, with no character animation.

Corresponding source:

# 文章 front-matter
subtitle: false

18.3 Full parameters

KeyAllowed valuesDefaultDescription
fun_features.typing.enabletrue / false—Master switch
typeSpeednumbertheme defaultPer-character interval; larger is slower
cursorCharany string\|Cursor character
looptrue / falsefalseWhether it replays after finishing
index.slogan.apiURLemptyFetches the subtitle from an endpoint (falls back to text on failure)

18.4 Boundaries & pitfalls

CaseBehaviour
Page unchanged after a config editHexo cache not invalidated → you must npm run clean && npm run build
page.subtitle: falseDisables it only on this page; the homepage is unaffected
index.slogan.api unreachableAutomatically falls back to the text field, never blank
Configured together with subtitle.typedSame source; fun_features.typing wins

18.5 Summary

  • Most used: fun_features.typing.enable: true
  • Adjust the speed: a larger typeSpeed is slower
  • Disable on one page: front-matter subtitle: false
  • Always clean-build after a change

Test assertion: tools/tests/rich-content-integration.test.js (L2o): the homepage .typed-cursor exists.


19. Social share (sharejs)

Purpose: a one-click share bar at the bottom of posts (Weibo / WeChat / QQ / Douban etc.), shown on post pages only.

Learning path: minimal example → platform subset → full parameters → alternative

19.1 Minimal example

Effect (description): a .social-share bar appears at the bottom of the post; the button order is determined by sites.

Corresponding source:

sharejs:
  enable: true
  # 支持顺序:twitter, facebook, google, qq, qzone, wechat, weibo, douban, linkedin
  sites: twitter,facebook,qq,qzone,wechat,weibo,douban

19.2 Common variants: keep only Chinese platforms

Effect (description): the share bar renders only the wechat,weibo,qq buttons.

Corresponding source:

sharejs:
  enable: true
  sites: wechat,weibo,qq

19.3 Full parameters

KeyAllowed valuesDefaultDescription
sharejs.enabletrue / false—Master switch
sharejs.sitescomma-separated platform namestheme defaultRender order = written order
Available platformstwitter / facebook / google / qq / qzone / wechat / weibo / douban / linkedin—Anything not in the list is not rendered
Render scopepage.layout == 'post' only—Not shown on the homepage or standalone pages

19.4 Alternative: addthis (mutually exclusive with sharejs)

Effect (description): the share bar is replaced by the AddThis implementation, with slightly different styling from the site’s own.

Corresponding source:

addthis:
  enable: false
  pubid: 613a04428f842fe1

19.5 Summary

  • Most used: sharejs.enable: true + a sites list
  • China only: wechat,weibo,qq is enough
  • Order follows the written order
  • Do not enable addthis at the same time: pick one

Test assertion: tools/tests/rich-content-integration.test.js (L2o): the .social-share component exists.


20. Live2D mascot

Purpose: a persistent Live2D model in the bottom-right corner (purely static, no PHP backend), interactive and swappable.

Learning path: minimal example → returning-visitor guard → full parameters → boundaries & pitfalls

20.1 Minimal example

Effect (description): the mascot appears in the bottom-right corner (#live2dcanvas / #waifu); it does not load on the first visit, only on the second.

Corresponding source:

live2dWidget:
  enable: true

20.2 Common variants: adjusting the returning-visitor threshold

Effect (description): by default it loads only when viewCount > 1; change the threshold to > 0 to load on the first visit too (at the cost of first-paint performance).

Corresponding source:

# 主题源码中的加载守卫(themes/matery 的 live2d 初始化)
# localStorage.viewCount > 1 才初始化模型

20.3 Full parameters

KeyAllowed valuesDefaultDescription
live2dWidget.enabletrue / false—Mascot master switch
Model directorystatic filessource/live2d/Cubism2 / Cubism5 dual runtime
Light/dark themefollows automatically—Switches model/colors in dark mode
Returning-visitor guardlocalStorage.viewCount > 1enabledDoes not load on first visit; performance protection

20.4 Boundaries & pitfalls

CaseBehaviour
Invisible on the first visitExpected behaviour (loads only when viewCount > 1)
Changing enable has no effectA clean build is required (Hexo cache)
The model does not moveCheck that source/live2d/ assets are complete (a skip_render static directory)
MobileUsually hidden to avoid covering content

20.5 Summary

  • Most used: live2dWidget.enable: true
  • Refresh twice when verifying (returning-visitor guard)
  • Models live in source/live2d/; both Cubism2 and Cubism5 work
  • Clean-build after a config change

Test assertion: tools/tests/rich-content-integration.test.js (L2o): after setting viewCount=3, the mascot container exists.


⚠️ Known pitfalls

Pitfall 1: double section numbering

Symptom: headings render as “1. 1. Overview” (two numbers).

Cause: theme CSS auto-numbers h2–h6 by default, which stacks on top of hand-written numbers (e.g. ## 1. Overview).

Fix: pages with hand-written numbering add closeAutoTocNum: true in front-matter; pages without hand-written numbering must not add that field.

This article already sets closeAutoTocNum: true correctly.

Pitfall 5: config changes require a clean build

Symptom: after changing tag-plugin configuration (e.g. post.mermaid.enable, live2dWidget.enable, sharejs.enable), the page does not change.

Cause: Hexo’s cache does not detect configuration changes automatically.

Fix: after changing config you must run npm run clean && npm run build.


Appendix: tag plugin quick reference

PluginSyntaxKey paramsFrontmatter needed
note{% note 颜色 %}内容{% endnote %}6 colorsno
timeline{% timeline 标题,颜色 %}...{% endtimeline %}title / colorno
tabs{% tabs 名称,序号 %}...{% endtabs %}name / indexno
label{% label 颜色@文字 %}color first, text afterno
button{% button 链接,文字,图标,title %}link first / text secondno
githubCard{% githubCard user:xx repo:yy %}user / repono
mermaid{% mermaid %}...{% endmermaid %}diagram typeyes (mermaid: true)
pdf{% pdf URL %}URLno
insertmd{% insertmd 'file.md' %}filenameno
wechat_dialog{% wechat_dialog %}User:/Assistant: 行{% endwechat_dialog %}User/Assistant linesno
groupimage{% groupimage 数量 布局 %}![图](url){% endgroupimage %}count / layoutno
cardurl{% cardurl [url=xxx] %}url / title / descno
admonition::: warning 内容 :::container :::; the original {% admonition %} tag is deprecatedno
encrypt{% encrypt 密码 "标题" "简介" %}...{% endencrypt %}password / title / descriptionno
math$...$ / $$...$$mathjax3 (SSR SVG) / katex engineyes (mathjax: true)
markmap{% markmap 350px %}列表{% endmarkmap %}height / features (math/prism/zoom)no
douban{% douban book\|movie\|music id %}type / id order interchangeable; covers localizedno
typewriterfun_features.typingtypeSpeed / cursorChar / loopno
sharesharejs.sitestwitter / wechat / weibo etc.no (post pages only)
Live2Dlive2dWidget.enablereturning-visitor guard viewCount>1no

References & credits

系列教程

全部文章RSS订阅

Hexo 主题功能测试系列


Hexo Theme Feature Test - Content Tags
Posted on
August 7, 2026
reprint policy. If reproduced, please indicate source
Support
Comments
Data Loading...
 Previous

Read More

Hexo Theme Feature Test - Interaction & Visual
Hexo Theme Feature Test - Interaction & Visual Hexo Theme Feature Test - Interaction & Visual
Complete tutorial and test for matery theme interaction & visual features: code block enhancements, image lightbox, type
2026-08-07
Current 

Read More

Hexo Theme Feature Test - Content Tags
Hexo Theme Feature Test - Content Tags Hexo Theme Feature Test - Content Tags
Complete tutorial and test for matery theme content tag plugins: note callouts, timeline, tabs, labels, buttons, githubC
2026-08-07