Hugo doesn’t support LaTeX-style math expressions by default — Markdown math syntax isn’t recognized out of the box.
Integrating MathJax, a JavaScript math display engine for all browsers, solves this problem.
The integration is straightforward: add the following to your article template HTML.
<script type="text/javascript" async src="https://cdn.bootcss.com/mathjax/2.7.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML">MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']], displayMath: [['$$','$$'], ['\[\[','\]\]']], processEscapes: true, processEnvironments: true, skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'], TeX: { equationNumbers: { autoNumber: "AMS" }, extensions: ["AMSmath.js", "AMSsymbols.js"] } }});
MathJax.Hub.Queue(function() { // Fix <code> tags after MathJax finishes running. This is a // hack to overcome a shortcoming of Markdown. Discussion at // https://github.com/mojombo/jekyll/issues/199 var all = MathJax.Hub.getAllJax(), i; for(i = 0; i < all.length; i += 1) { all[i].SourceElement().parentNode.className += ' has-jax'; }});</script>
<style>code.has-jax { font: inherit; font-size: 100%; background: inherit; border: inherit; color: #515151;}</style>Make sure this HTML is loaded by the Hugo framework on every page. I added it to layouts/partials/footer.html since that file is guaranteed to be included on every page.
The pure MathJax integration doesn’t actually require this much code — the extra parts resolve conflicts between Markdown and LaTeX’s different interpretations of the underscore _. For details, see this article.
Now enjoy LaTeX in Hugo!
Last edited 04/06/2026