How to allow hexo render LaTeX formulas correctly

How to render LaTeX\LaTeX formulas in hexo blog (theme ‘fluid’)

By default, LaTeX\LaTeX formulas are not rendered and cannot be correctly displayed. To fix this, the first step is to uninstall the default renderer and install KaTeX\KaTeX renderer. ( mathjax\mathrm{mathjax} is also an alternative, but it may fail to render some complex formulas).

In terminal, cd to your hexo directory, and run the following

1
npm uninstall hexo-renderer-marked --save

and then

1
npm install hexo-renderer-markdown-it-plus --save

To get a better view, hexo-math plugin (by hexo official) is recommended, which makes your math text looks better.

1
npm install hexo-math --save

After that, modify some configurations:

In ‘fluid’ theme _config.fluid.yml, modify the corresponding part to the following:

1
2
3
4
5
post:
math:
enable: true
specific: true
engine: katex

Note that specific means to only enable formula conversion when math: true is found in front-matter, in order to boost loading speed when no formula.

Finally,

1
hexo clean && hexo generate 

Reference: link


How to allow hexo render LaTeX formulas correctly
https://www.billhu.us/2022/10_hexo_katex/
Author
Bill Hu
Posted on
January 16, 2022
Licensed under