Creating a Blog Post using a Jupyter Notebook

blogging
quarto
jupyter
Author

Christian Wittmann

Published

October 18, 2022

This is somehow a “Hello World”-notebook, since its only purpose is to demonstrate how you can use a jupyter notebook to write a blog post using Quarto.

Somehow I did not find the key ingredient in the Quarto docs, but in this blog post: To get the necessary header data into the jupyter notebook, you need to add a RAW-cell at the top which contains the metadata. This is how this cell looks like in this notebook (and here is an hello-world example):

---
title: "Creating a Blog Post using a Jupyter Notebook"
author: "Christian Wittmann"
date: "2022-10-18"
categories: [blogging, quarto, jupyter]
image: "jupyter_logo.png"
---

Jupyter Notebook (.ipynb) vs. Quarto (.qmd)

For my current use case of blogging I prefer the jupyter notebooks, and I will most likely write all future blog posts in jupyter notebooks because of the following:

  • My spell checking addon for VS Code does not support .qmd files.
  • With jupyter notebook there is no need to render the files, rendering is instant in jupyter notebook when you execute the cell.
  • Jupyter notebook is the same environment when I code, no need to adjust (even if only slightly)

Of course, all of this is very personal and a current snapshot of preferences (as a beginner) - let’s see if this solidifies or changes.

How is code rendered?

Let’s try out a little bit of code:

Hello World

print("Hello World!")
Hello World!

Calculations

a = 1
b = 2
c = a+b
print(c)
3

Plotting

import matplotlib.pyplot as plt
    
x = [1,2,3]
y = [2,4,1]
    
plt.plot(x, y)
    
plt.xlabel('x - axis')
plt.ylabel('y - axis')
plt.title('Sample graph')
    
plt.show()