Maths
Formulas with MathJax, on the pages that ask for it.
Turning it on
Markdown would read the backslashes in \( and \[ as escapes and drop them before MathJax sees the formula. Hugo’s
passthrough extension leaves formulas untouched; add it to your hugo.toml once:
[markup.goldmark.extensions.passthrough]
enable = true
[markup.goldmark.extensions.passthrough.delimiters]
block = [['\[', '\]'], ['$$', '$$']]
inline = [['\(', '\)']]Then add math: true to a page’s front matter, or turn it on for every page:
[params]
math = trueA page can then turn it off with math: false. MathJax 4 loads only on pages with maths turned on.
Writing formulas
In-line maths goes between \( and \), display maths between $$ lines (or \[ and \]):
The identity \(e^{i\pi} + 1 = 0\) and the integral
$$
\int_0^1 x^2 \, dx = \frac{1}{3}
$$The identity \(e^{i\pi} + 1 = 0\) and the integral
$$ \int_0^1 x^2 , dx = \frac{1}{3}