Hexo中启用Katex

首先你需要下载插件:

1
2
3
4
5
6
npm un hexo-renderer-marked --save # 如果有安装这个的话,卸载
npm un hexo-renderer-kramed --save # 如果有安装这个的话,卸载

npm i hexo-renderer-markdown-it --save # 需要安装这个渲染插件
npm install katex @renbaoshuo/markdown-it-katex #需要安装这个katex插件

然后在hexo的根目录的 _config.yml 中配置:

1
2
3
4
markdown:
plugins:
- '@renbaoshuo/markdown-it-katex'

最后在Butterfly的配置文件中找到math,改为:

1
2
3
4
5
6
7
8
9
# About the per_page
# if you set it to true, it will load mathjax/katex script in each page
# if you set it to false, it will load mathjax/katex script according to your setting (add the 'mathjax: true' or 'katex: true' in page's front-matter)
math:
# Choose: mathjax, katex
# Leave it empty if you don't need math
use: katex
per_page: true
hide_scrollbar: false