To write about machine learning, I will naturally want to use some math symbols. Using LaTeX math in Jekyll is not completely straightforward, so I will describe the process here.

The markdown syntax itself is straightforward enough. Suppose we want to write $\nabla_\boldsymbol{x} J(\boldsymbol{x})$. The LaTeX code for this is $\nabla_\boldsymbol{x} J(\boldsymbol{x})$. The markdown syntax uses \$ one more time in each delimiter: $$\nabla_\boldsymbol{x} J(\boldsymbol{x})$$. So far so good.

Unfortunately, if we build the markdown and display the site, none of the LaTeX expressions appear. This is because we need to include MathJax, a JavaScript library that does the actual rendering. All of the instructions I have been able to find say to include this script by modifying _layouts/post.html, but newer versions of Jekyll do not create such a file by default.

Instead, we need to find the layout file bundled with the theme, make our own copy of it in our local repository, then modify that copy. To find the files for the minima theme, we run bundle show minima. Now we can copy post.html and add the following to it:

<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>


MathJax will now render simple LaTeX expressions correctly. Jekyll and MathJax do not offer all of the functionality of LaTeX—there is no support for the LaTeX usepackage command, so only the core LaTeX functionality that has been ported to MathJax is available. This is why I use boldsymbol rather than bm above. There seem to be a few other rough edges, for example, LaTeX expressions seem to cause extraneous line breaks when used in blog post titles.