Hexo 博客文章支持 LaTeX 语法渲染
Abstract: 用 `hexo-renderer-markdown-it`,搭配 KaTeX 使 Hexo 博客支持 LaTeX 语法渲染。
本文由上上篇文章而来(
废话不多说,直接上干货。
1. 替换渲染引擎
1.1 删除 Hexo 原有渲染引擎
Hexo 原使用 hexo-renderer-marked 作为 Markdown 渲染引擎。
在 Hexo 根目录运行:
1 | npm un hexo-renderer-marked --save |
1.2 安装新引擎
用 hexo-renderer-markdown-it ,搭配 @renbaoshuo/markdown-it-katex 来解决。
继续在 Hexo 根目录运行:
1 | npm i hexo-renderer-markdown-it katex @renbaoshuo/markdown-it-katex --save |
2. 修改配置
2.1 Hexo 配置修改
在 Hexo 根目录找到 _config.yml,末尾添加解析规则:
1 | markdown: |
2.2 主题配置修改
在主题目录中打开 _config.yml (./themes/[YOUR_THEME]/_config.yml),找到 math 或 katex 相关配置项(Ctrl + F 搜索)
以下以 Butterfly 为例:
1 | # Math (數學) |
3. 按需开启
需要在某一篇文章里启用 LaTeX 渲染时,在其 .md 文件开头 Front-matter 中添加启用即可。
1 | --- |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.



