Skip to main content

Build clean, searchable static books from marimo notebooks and markdown

Project description

marimo-book

PyPI version Python versions CI License: MIT Docs

Build clean, searchable static books from marimo notebooks and Markdown files.

marimo-book is a Jupyter-Book-style static site generator built specifically for marimo .py notebooks. It produces polished multi-page sites with:

  • Anywidgets that render statically — interactive Canvas/Three.js/Plotly widgets without a marimo kernel
  • Static reactivity for discrete sliders (mo.ui.slider with explicit steps) — pre-rendered lookup tables, no kernel
  • WASM render mode per chapter — opt into Pyodide-driven full reactivity for chapters that need it
  • Material for MkDocs theming — full-text search, dark mode, code-copy, breadcrumbs, responsive layout
  • Launch buttons per chapter — molab / GitHub / download .py
  • Incremental build cache — content-hashed; only changed chapters re-render
  • GitHub Pages deploy workflow scaffolded by marimo-book new

Status

Alpha (0.1.x). Used in production by at least one real course (dartbrains.org). The book.yml schema is stable for v0.1; pin a minor version (marimo-book>=0.1.5,<0.2) until 1.0. Major changes always go through a new minor version.

Install

pip install marimo-book

Requires Python 3.11+. Optional extras for opt-in features:

pip install 'marimo-book[social]'      # OpenGraph card generation (libcairo)
pip install 'marimo-book[linkcheck]'   # external-link verification (htmlproofer)
pip install 'marimo-book[pdf]'         # single-PDF export (WeasyPrint)

mkdocs-autorefs (cross-page heading references) ships in the base install — flip cross_references: true in book.yml to enable.

Quickstart

# Scaffold a new book
marimo-book new mybook
cd mybook

# Live-reload dev server (http://127.0.0.1:8000/)
marimo-book serve

# One-shot static build (emits ./_site/)
marimo-book build

# Validate book.yml + content without building
marimo-book check

# Remove build artifacts
marimo-book clean

Deploy to GitHub Pages by pushing the scaffolded workflow (.github/workflows/deploy.yml) to the default branch on a repo with Pages enabled.

How it works

Two-stage build, by design:

content/*.md + *.py + book.yml
  → marimo-book preprocessor
  → _site_src/docs/*.md  +  _site_src/mkdocs.yml
  → mkdocs build (Material theme)
  → _site/

The preprocessor is not a mkdocs plugin — it emits plain Markdown + inline HTML. This keeps the shell swappable: Material today, zensical (Material's Rust successor) tomorrow, or a hand-rolled Jinja shell as a last-resort fallback.

For each marimo .py it runs marimo export ipynb --include-outputs and translates the cells into Markdown + inline HTML — embedding Plotly figures, anywidget mounts, and matplotlib renders directly. For WASM-mode chapters, it routes through marimo's MarimoIslandGenerator and ships marimo's runtime + Pyodide bundle.

book.yml minimal example

title: My Book
description: A static site from marimo notebooks + Markdown.
authors:
  - name: Your Name
repo: https://github.com/you/yourbook

theme:
  palette:
    primary: "#1976D2"

launch_buttons:
  molab: true
  github: true
  download: true

# Static reactivity for discrete mo.ui widgets
precompute:
  enabled: true

toc:
  - file: content/intro.md
  - section: Chapters
    children:
      - file: content/chapter1.py
      - file: content/chapter2.py
        mode: wasm           # this one runs in Pyodide for full reactivity

See marimo-book new for the full starter template, and the book.yml reference for every field.

Notebook dependencies

book.yml picks one of two modes:

  • env (default): re-use the active venv. Pin notebook deps in your book root's pyproject.toml. Fast.
  • sandbox: pass --sandbox to marimo export. Each notebook declares its own deps via PEP 723 inline metadata; marimo provisions per-notebook envs via uv. Slower on first run; portable.

Override per invocation with --sandbox / --no-sandbox on build or serve.

Build cache

A content-addressed cache at {book_root}/.marimo_book_cache/ skips re-rendering chapters whose source + book.yml-relevant fields haven't changed. Typical incremental rebuilds drop from 100+ s to ~3 s on real-world books. Reset with marimo-book clean or override per invocation with marimo-book build --rebuild. CI runners get warm cache reuse via actions/cache@v4.

Broken-link checking

marimo-book build --strict fails on broken in-tree links and anchors (use this on CI). For external URL and image src validation, opt into htmlproofer:

# book.yml
check_external_links: true
pip install 'marimo-book[linkcheck]'
marimo-book build --strict

External link checking hits the live web (~1–3 s per link), so we recommend gating it behind a release-cutting workflow rather than running on every PR.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marimo_book-0.1.23.tar.gz (269.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marimo_book-0.1.23-py3-none-any.whl (119.7 kB view details)

Uploaded Python 3

File details

Details for the file marimo_book-0.1.23.tar.gz.

File metadata

  • Download URL: marimo_book-0.1.23.tar.gz
  • Upload date:
  • Size: 269.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for marimo_book-0.1.23.tar.gz
Algorithm Hash digest
SHA256 17b9d6494165372f98d8b15f9dea9cadf5500e9b0df9d9e9c51ef0910a45a277
MD5 613b1a65aa8c317d581132efe0be520d
BLAKE2b-256 48fb697a7798b99bba66973c0d135edc9dd121fc76083995469d6f6ab573b9bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for marimo_book-0.1.23.tar.gz:

Publisher: publish.yml on ljchang/marimo-book

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file marimo_book-0.1.23-py3-none-any.whl.

File metadata

  • Download URL: marimo_book-0.1.23-py3-none-any.whl
  • Upload date:
  • Size: 119.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for marimo_book-0.1.23-py3-none-any.whl
Algorithm Hash digest
SHA256 8a96096d6ee1efe8c1da932a3ffc036a9fa69bdc1a6eade51afcfaf7686fce6e
MD5 5e390792f03b60388ff020545e57eff6
BLAKE2b-256 ddd9715a874cd9558dfc6310eead62c25f9e6e1972636c2a7dff5d397c493916

See more details on using hashes here.

Provenance

The following attestation bundles were made for marimo_book-0.1.23-py3-none-any.whl:

Publisher: publish.yml on ljchang/marimo-book

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page