Skip to main content

quarto-prerender

Render Quarto .qmd files to Markdown, designed to work as a pre-processor for static site generators.

.qmd → .md + figures

Installation

# Requires Quarto CLI
brew install quarto  # macOS

# Install the tool
uv sync

Python Environment for Notebooks

Quarto needs a Python environment with Jupyter and your notebook dependencies (numpy, matplotlib, etc.). Create a separate data science venv:

# Create the environment
uv venv ~/envs/datascience --python 3.12

# Install packages
uv pip install --python ~/envs/datascience/bin/python \
  jupyter numpy matplotlib pandas

# Use it with quarto-prerender
quarto-prerender pages/ --python ~/envs/datascience/bin/python

Add more packages as needed for your notebooks.

Usage

# Render all .qmd files in a directory
quarto-prerender pages/

# With options
quarto-prerender pages/ \
  --cache .quarto_cache \
  --assets pages/assets/quarto \
  --force

# Watch mode
quarto-prerender pages/ --watch

# Verbose output
quarto-prerender pages/ -v

How It Works

  1. Finds all .qmd files in the target directory
  2. Runs quarto render with GFM output format
  3. Moves generated figures to assets/quarto/{path}/
  4. Fixes figure paths in the generated .md
  5. Preserves original frontmatter (public, published, etc.)

Directory Structure

pages/
├── analysis/
│   ├── report.qmd          # Source
│   └── report.md           # Generated
└── assets/
    └── quarto/             # Generated figures
        └── analysis/
            └── report_files/
                └── figure-1.png

Obsidian Integration

Use the qmd-as-md-obsidian plugin to edit .qmd files in Obsidian.

Example .qmd File

---
title: "Analysis Report"
public: true
date: 2025-01-15
tags: [ml, analysis]
execute:
  freeze: auto
jupyter: python3
---

# Model Performance

```{python}
#| label: fig-loss
#| fig-cap: "Training loss over epochs"
#| out-width: "600px"

import matplotlib.pyplot as plt
import numpy as np

epochs = np.arange(100)
loss = np.exp(-epochs/20) + 0.1 * np.random.randn(100)

plt.figure(figsize=(10, 6))
plt.plot(epochs, loss)
plt.xlabel("Epoch")
plt.ylabel("Loss")
plt.show()

## Figure Sizing

Figures are responsive by default (no fixed width). To set a specific width for a figure, use Quarto's `out-width` option:

```python
#| out-width: "600px"

For responsive images on mobile, ensure your site's CSS includes img { max-width: 100%; }.

Gitignore

Add to your content repository's .gitignore:

# Quarto cache
.quarto_cache/

# Generated figures
assets/quarto/

Metadata

Release files for quarto-prerender 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quarto-prerender 0.1.0
File Size Uploaded
quarto_prerender-0.1.0.tar.gz 19.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for quarto-prerender 0.1.0
File Interpreter ABI Platform
quarto_prerender-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.0 kB

Release files / quarto_prerender-0.1.0.tar.gz

Download URL quarto_prerender-0.1.0.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cf2b9355d15b977ca20e3569ccd956c56c817ad11c3fb80259e367b15d52e7a2
BLAKE2b-256 checksum
How to use checksums
e80f79e1a277d55a8ddb6ab5b700394667e4c78cfac02cc6fddd55139ca7753e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.12

Release files / quarto_prerender-0.1.0-py3-none-any.whl

Download URL quarto_prerender-0.1.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8cdbeb7ac5532bcbea10d9281670f7763ddcd5d10e808c3461f77b89c8fd0ad
BLAKE2b-256 checksum
How to use checksums
85959f1d1535d5d5f5d6c8e0eeceaeb39c2c6cc9be7f4279940aa81f20f1f3f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page