I use Quarto for my website

Published

July 10, 2022

Yes, the website you are seeing right now.

I used to use a simple Python web server and some routings to render the contents I wrote in Markdown. It is quite nice, to be honest, until found Quarto.

I came across Quarto in a hackernews discussion (forgot which one). It allows me to write technical writings and export them to various formats, such as PDF, HTML, MS Word, etc., thanks to Pandoc, on top of which Quarto sits.

I have a certain preference for a web and blogging tool/platform:

Quarto has them all. I can simply write the contents and it effortlessly render them as HTML files. But there is one extra that makes me close the deal: Quarto supports code execution and immediate output display. The supported languages are Python, R, Julia, and Observable. Simply write the code inside a conde-fence and it will be executed.

import math
import numpy as np
import matplotlib.pyplot as plt

sinusoid = [
    math.sin(x) for x in np.linspace(0, 10*math.pi, 500)
]

plt.plot(sinusoid)

The example above shows a plot using IPython inline backend. We can also display pandas dataframes nicely as follows.

import pandas as pd
from sklearn.datasets import load_iris

X, y = load_iris(return_X_y=True)
df = pd.DataFrame(
    X, columns=['sepal length', 'sepal width', 'petal length', 'petal width']
)

df.head()
sepal length sepal width petal length petal width
0 5.1 3.5 1.4 0.2
1 4.9 3.0 1.4 0.2
2 4.7 3.2 1.3 0.2
3 4.6 3.1 1.5 0.2
4 5.0 3.6 1.4 0.2

This immensely simplifies the workflow, especially when I write tutorials or other technical writings. I don’t need to go back and forth between authoring and coding activities to generate result. I can just write the code and the result will be displayed right away.

The generated HTML files are very customizable. The output is minimum but has reasonable defaults. I can easily integrate my existing web contents (even the look and feels).

You should try it too!

Note

I also ported my ML From Scratch writings into website format using Quarto. You can access it here.