A minimal static blog engine powered by Typst. Write posts in Typst instead of Markdown and get a fast, clean static site — out of a single self-contained binary.
papyr links Typst in as a library and ships its own dev server and file watcher,
so there's no external toolchain to wrangle: no Node, no Python, no separate
Typst CLI, no static-server sidecar. Just papyr.
- Zero client-side JS. Code is syntax-highlighted and math is rendered to native MathML at build time — nothing ships to the browser but HTML and CSS.
- Live reload.
papyr serverebuilds on save and refreshes the open page. - Light + automatic dark mode, with self-hosted fonts.
- Posts, tags, an RSS feed, and standalone pages out of the box.
- One compile per file. The HTML and the post's metadata come from the same compiled document via introspection — no double-compile, no shelling out.
cargo install papyr # see Install for Nix / prebuilt binaries
papyr init my-blog && cd my-blog
papyr serve # http://localhost:8080, live-reloads on saveEdit a file under posts/ and the page reloads itself. When you're happy,
papyr build writes the static site to ./site/.
nix run github:n2dio/papyr -- init my-blog # run without installing
nix profile install github:n2dio/papyr # install `papyr` into your profilecargo install papyr # from crates.io
cargo install --git https://github.com/n2dio/papyr # latest from gitMake sure ~/.cargo/bin is on your PATH.
Grab a tarball for your platform (Linux x86_64/aarch64 musl, macOS
x86_64/aarch64) from the latest release,
then extract papyr onto your PATH.
cargo install --path . # optimized → ~/.cargo/bin/papyr (or: just install)While iterating, skip the slow optimized rebuild — just install-fast symlinks
the incrementally-built debug binary onto your PATH, so a plain just build
(~1s) updates papyr live. Run just install for the optimized binary when done.
papyr init my-blog # scaffold a new site
cd my-blog
papyr serve # build, serve http://localhost:8080, rebuild + live-reload on change
papyr new my-post # scaffold posts/my-post.typ
papyr build # build the static site into ./site
papyr build --strict # ...and fail if any internal link is broken (CI)
papyr eject style.css # copy a built-in default onto disk to own it
papyr migrate # drop engine files identical to the defaults
papyr clean # remove build artifactsAdd -v / --verbose for per-file compile timings, HTTP request logs, and
watcher events.
Create posts/<slug>.typ (the filename becomes /posts/<slug>.html):
#import "/lib/template.typ": post
#show: post.with(
title: "My post title",
date: "2026-01-01", // date or full timestamp (see below)
tags: ("typst", "web"),
summary: "Shown on the home page and in the feed.",
)
Write prose in normal Typst markup. Inline `code`, fenced blocks, and math
(`$ E = m c^2 $`) all work.date accepts either a plain date or a full timestamp, and drives ordering, the
RSS pubDate, and the <time datetime> attribute (only the date is shown):
2026-01-01 # date only (midnight UTC)
2026-01-01 14:30:00 # date + time (UTC)
2026-01-01T14:30:00+02:00 # date + time with offset
papyr new stamps the current local time, so same-day posts order correctly.
Link between pages with the helpers (validated at build time):
#import "/lib/template.typ": post, post-link, page-link
See #post-link("other-post")[that post] or the #page-link("about")[about page].Typst Universe packages work too — they're downloaded on demand into the standard Typst cache:
#import "@preview/cetz:0.3.1": canvas // fetched + cached on first buildCallout boxes for technical notes:
#import "/lib/template.typ": post, note, tip, warning, todo
#note[Heads up.] #tip[Do this.] #warning[Careful.] #todo[Finish this.]Set toc: true in a post's show: post.with(...) to get a collapsible table of
contents (headings always get hover anchors regardless).
- Prev/next navigation between posts, heading anchors, and an opt-in TOC.
- Social/SEO
<head>: OpenGraph + Twitter card,description, canonical URL, light/darktheme-color. - Discovery:
sitemap.xml,robots.txt, and RSS feed autodiscovery. - Print: an ink-friendly
@media printstylesheet for clean PDFs. - A broken-internal-link check (fail the build with
--strict).
papyr init scaffolds your content — that's all a site needs:
| Path | Purpose |
|---|---|
config.yaml |
Site title, tagline, author, URL, description. Optional: a nav: list of {label, href} for the header, and imprint: (true → /imprint.html, or a path) for a footer imprint link. |
posts/*.typ, pages/*.typ |
Content. |
The engine comes from the binary, not your repo. These paths resolve to papyr's built-in defaults unless you create the file yourself:
| Path | Purpose |
|---|---|
lib/template.typ |
Shared post/page show-rules, nav + footer, link helpers. |
lib/custom.typ |
Your Typst additions — re-exported through the template. |
gen/*.typ |
Index, tag, and tags-index listing pages. |
assets/style.css |
Stylesheet. |
assets/custom.css |
Your CSS — appended after the default stylesheet. |
assets/code-theme.tmTheme |
Dark syntax theme for code blocks. |
assets/fonts/*.woff2 |
Self-hosted IBM Plex Sans + JetBrains Mono. |
Favicons (favicon.svg, favicon.ico, apple-touch-icon.png) are picked up
from assets/ when you add them.
papyr ships its engine — the template, listing pages, stylesheet, code theme, and
fonts — inside the binary. A fresh papyr init writes only your content
(config.yaml, posts/, pages/), and every build uses the engine from the
papyr version you run, so improvements arrive on upgrade with nothing to copy.
Customize without giving that up:
- CSS: add
assets/custom.css. It's appended after the default stylesheet, so you can override CSS variables (--accent,--callout-accent, …) or add rules (e.g. a.callout-spoilercolor). - Typst: add
lib/custom.typ. Anything you#letthere is re-exported through/lib/template.typ, so posts can use it — re-bind a default (e.g.note) or add a new helper (e.g. aspoilercallout to go with that CSS).
// lib/custom.typ
#let spoiler(body) = html.elem("div", attrs: (class: "callout callout-spoiler"), body)// posts/whodunnit.typ — `spoiler` arrives via the template
#import "/lib/template.typ": post, spoiler
#spoiler[the butler did it]For full control of a file, run papyr eject <target> (template, style.css,
code-theme, gen, fonts, or all). The ejected file lands on disk and wins
over the default — but no longer auto-upgrades.
Have an existing site with the engine checked in? Run papyr migrate: it deletes
engine files identical to the current defaults and reports any you customized
(left in place as overrides).
This repo is the engine. The default lib/, gen/, and assets/ are baked
into the binary by src/embedded.rs (via include_bytes!) and served to sites
that don't override them; the CLI and build logic are in src/.
A dev shell with the full toolchain (cargo, rustc, rustfmt, clippy, just) is
provided via Nix — nix develop (flake) or nix-shell (legacy). With direnv
it loads automatically on cd (run direnv allow once).
just build | release | install | install-fast | test | check | fmt | lintNotes: Typst's HTML export is still officially experimental; this pins Typst
0.15 and upgrades deliberately. Math is native MathML (Typst 0.15). Code
blocks are dark in both themes because Typst bakes syntax colors in at build
time.
MIT © Tim Eggert.