How to publish a jupyter notebook on Github pages with Jekyll

Adding Jupyter Notebook Support to GitHub Pages

Jupyter notebook support is added with the jekyll-jupyter-notebook Ruby gem from

https://github.com/red-data-tools/jekyll-jupyter-notebook

Install this gem, and then you will be able to add jupyter notebooks to your GitHub pages. To use the extension, make a new Markdown post, and then link to a Jupyter notebook that is contained somewhere else in the source code of the GitHub website.

Linking is done by:

{percent jupyter_notebook "path_to_notebook.ipynb" percent}

where percent above needs to be replaced by %, so that it is proper liquid code. This will insert the Jupyter notebook into the new post.

Support for Latex Equations Numbering in Jupyter Notebook

So far, the easiest way I have found to insert Latex and being able to reference equations is by following this StackOverflow comment

\begin{equation*}
\mathbf{r} \equiv \begin{bmatrix}
y \\
\theta
\end{bmatrix}
\label{eq:vector_ray} \tag{1}
\end{equation*}

Vector **r** is defined by equation $\eqref{eq:vector_ray}$

Note that this only works in Jupyter because it uses MathJax. The VSCode latex rendered uses Katex, so it will note be able to render these properly. Since MathJax is also used for the rendering of the equations in the al-folio Jekyll theme, then it should render the equations fine.




Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • Probability Theory
  • Gaussian process regression introduction