Skip to content

Instantly share code, notes, and snippets.

@mathwo
Created July 10, 2024 18:39
Show Gist options
  • Select an option

  • Save mathwo/4958a7e50be85743615c18d9e34109e9 to your computer and use it in GitHub Desktop.

Select an option

Save mathwo/4958a7e50be85743615c18d9e34109e9 to your computer and use it in GitHub Desktop.
How to add MathJax support to Zola Static Site Generator
Step 1: follow the instructions on this [starting guide](https://www.getzola.org/documentation/getting-started/overview/)
Step 2: add following piece of code in templates/blog-page.html (before the last line):
```
{% if page.extra.math %}
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
}
};
</script>
<script type="text/javascript" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
</script>
{% endif %}
```
Step 3: In the head of each post markdown file, add two lines:
```
[extra]
math = true
```
Then you can use MathJax latex expressions in the markdown posts.
Note: Single $ for inline math, $$ for block math, \newline for new line break.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment