From Juptyer to Blog

Fun with Notebooks

Image credit: Martin Krasser

The following post was made by creating a Jupyter notebook and converting it to a blog post, using the nbconvert tool.

jupyter nbconvert --to markdown Test\ Notebook\ Blog\ Post.ipynb --NbConvertApp.output_files_dir=.

The command above will convert the notebook to Markdown and save it in the same directory as the notebook. Adding the usual Hugo front matter to the markdown file will allow it to be rendered as a blog post. Assuming you already have an index.md file with front matter, something like:

cat 'Test Notebook Blog Post.md' | tee -a index.md

…will do the trick!

Test Notebook Blog Post

import matplotlib.pyplot as plt
import numpy as np

Let’s do something a bit random!

X = np.random.rand(100).reshape(10,10)
plt.imshow(X)
<matplotlib.image.AxesImage at 0x1248bd4b0>

png