I’ve been working a bunch with jupyter notebooks recently, and was looking for an easy way to include the notebooks on this blog to demonstrate code examples easily.

Here is the rough workflow I’ve developed:

  1. Add and edit jupyter notebooks in a _notebooks folder of the blog repository.
  2. Convert it with jupyter nbconvert --to html notebook.ipynb.
  3. Move the conversion to the _posts folder.
  4. Add the standard Jekyll metadata (title, etc.) with the layout set as notebook (this is a custom layout for Jupyter notebooks).

This is a slightly modified workflow from another Jekyll post I found here. The main difference is that I am exporting in HTML, rather than markdown, so the default jupyter notebook HTML formatting for code cells and their output is preserved.

Here is a link to an example post generated from notebook.