Skip to content


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation

Hexo Filter MathJax

npm-image lic-image

Server side MathJax Renderer Plugin for Hexo.

WARNING: This plugin is a server-side math rendering plugin, which does not depend on any front-end scripts. If you have already enabled other math rendering methods before installing this plugin, please do the following to avoid conflicts:

  • Remove all other Hexo math plugins
  • Disable front-end math renderer in Hexo theme settings (For theme NexT, you need to set both math.mathjax.enable and math.katax.enable to false)
  • Delete front-end scripts related to math rendering


size-image dm-image dt-image

$ npm install hexo-filter-mathjax
$ hexo clean


You can configure this plugin in Hexo _config.yml. Default options:

  tags: none # or 'ams' or 'all'
  single_dollars: true # enable single dollar signs as in-line math delimiters
  cjk_width: 0.9 # relative CJK char width
  normal_width: 0.6 # relative normal (monospace) width
  append_css: true # add CSS to pages rendered by MathJax
  every_page: false # if true, every page will be rendered by MathJax regardless the `mathjax` setting in Front-matter
  packages: # extra packages to load
  extension_options: {}
    # you can put your extension options here
    # see for more detail


Set mathjax: true in Front-matter of each article (post / page) that you would like to enable MathJax. For example:

title: On the Electrodynamics of Moving Bodies
categories: Physics
date: 1905-06-30 12:00:00
mathjax: true

Then you can use the LaTeX syntax in the article.


hexo-renderer-pandoc is recommended because it can handle mathematical formulas in markdown documents perfectly. But you need to be aware that inline Math (..$...$) must not have white spaces after the opening $ and before the ending $. For example:

-$ \epsilon_0 $
-$ \frac{\partial}{\partial t} $
+$\frac{\partial}{\partial t}$

If you are using other renderers, such as hexo-renderer-marked, you need to be aware of the conflict between LaTeX and Markdown syntax. For example, an underscore (_) may be interpreted as the start of italic text in Markdown, or subscripted mark in TeX. Use \ to escape if necessary:



Write the following LaTeX code:

i\hbar\frac{\partial}{\partial t}\psi=-\frac{\hbar^2}{2m}\nabla^2\psi+V\psi
\nabla\times\vec{E}&=&-\frac{\partial B}{\partial t}\\\\
\nabla\times\vec{B}&=&\mu_0\left(\vec{J}+\epsilon_0\frac{\partial E}{\partial t}\right)\\\\

Then you will get:

Known Issues

Long equations with labels may cause horizontal overflow, because a min-width CSS property will be added to mjx-container elements by MathJax.


Released under the MIT License