hexo-renderer-mathjax
v0.9.0
Published
MathJax renderer plugin for Hexo
Readme
MathJax Renderer Plugin for Hexo
Add support of MathJax for Hexo.
The plugin injects the MathJax script into every generated page through Hexo's injector, so it works with any theme and any template engine.
REQUIREMENTS
- Hexo 5.0.0 or above
- Node.js 20 or above
- A renderer for your theme's templates, e.g.
hexo-renderer-ejsfor EJS themes —hexo initand every EJS theme already pull it in
INSTALL
$ npm install hexo-renderer-mathjax --saveThat is all — Hexo loads plugins from package.json automatically, and the
defaults need no _config.yml change.
Sample
Write the following latex code:
$$
\frac{\partial u}{\partial t} = h^2 \left( \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} + \frac{\partial^2 u}{\partial z^2}\right)
$$Then you will get:

CONFIGURATION
By default MathJax 2.7.9 is loaded from cdnjs with a pinned subresource
integrity hash. If that CDN is slow or blocked for your readers, point the
plugin at another one from your site's _config.yml:
mathjax:
src: https://cdn.jsdelivr.net/npm/[email protected]/MathJax.js?config=TeX-AMS-MML_HTMLorMML| Option | Default | Description |
| ----------- | --------------------------- | -------------------------------------------------- |
| src | the cdnjs MathJax 2.7.9 URL | URL of MathJax.js, including its ?config= query |
| integrity | the hash for that URL | Subresource integrity hash for src |
Notes:
Keep the
?config=TeX-AMS-MML_HTMLorMMLquery (or another combined config that includes the TeX input and an HTML output) — the injected snippet configures MathJax 2.x throughMathJax.Hub.Config.The bundled
integrityhash only matches the cdnjs payload, so setting your ownsrcdrops it. Addintegrityyourself to keep the script pinned:mathjax: src: https://cdn.jsdelivr.net/npm/[email protected]/MathJax.js?config=TeX-AMS-MML_HTMLorMML integrity: sha384-...To serve MathJax from your own site instead, put the files under
source/and setsrcto the resulting path.
