Modules
A module is a directory containing a tola-module.toml manifest. It can expose Typst libraries, Nu helpers, static assets, or CLI subcommands—or declare [build] entry to supply a complete site theme.
Sources
Register modules in tola.toml under [modules.<alias>]. Aliases are chosen by the site, and the same module can be mounted under multiple aliases with distinct options. Use path for a local directory, git for a Git repository, or tarball for a release archive:
[build]
entry = { module = "notes" }
[modules.notes]
path = "theme"
[modules.notes.options]
show-title = true[modules.theme]
git = { url = "https://github.com/example/tola-theme.git", tag = "v1.0.0", subdir = "dist/theme" }[modules.theme]
tarball = { url = "https://example.com/theme-v1.0.0.tar.gz", sha256 = "0123..." }path: resolves relative totola.toml(must stay inside the site directory under--pure).git: specify at most one oftag,branch, or fullrev(defaults to the remote default branch), plus optionalsubdir. HTTPS uses Git credential helpers; SSH uses your local SSH config.tarball: acceptsurlor localpathin.tar.gz,.tar.zst, or.zipformat with optional 64-hexsha256. Archives must have one top-level directory containingtola-module.toml; extracting an archive does not run author packaging hooks, so point to pre-packed release archives.
Once registered, import a module’s Typst library with #import "@tola-modules/<alias>:0.0.0": * and inspect module commands with tola <alias> --help. Remote digests lock into tola.lock; run tola update <alias> to upgrade.
Official modules
The official modules are released independently of Tola. The examples below select the default branch. tola.lock fixes the resolved commit until you refresh it with tola update.
tailwind
Scans Tola’s compiled HTML pages and builds Tailwind CSS v4:
[modules.tailwind]
git = { url = "https://github.com/tola-rs/modules.git", subdir = "tailwind" }
[modules.tailwind.options]
runner = "auto" # or an explicit argv list, e.g. ["bunx", "--no-install", "@tailwindcss/cli"]
minify = false
dev = "run" # "run" | "reuse" | "skip"Install the Tailwind CSS v4 CLI, for example with npm install --save-dev tailwindcss @tailwindcss/cli. Automatic lookup checks the directory that declared the module, then the site root, then PATH.
Include output-url("_tola-modules/tailwind/tailwind.css") (matching your alias) in <head>. To add custom CSS or explicit @source directives, create styles/tailwind.css starting with @import "tailwindcss" source(none);. CSS imports and plugins resolve from the stylesheet’s directory. Use toolchain to identify extra dependencies for the disk cache.
resize-images
Batch-resizes JPEG, PNG, and WebP images declared under [assets] and caches each width separately (ideal for photo galleries; prefer @tola/image for per-image sizing in content):
[assets]
trees = [{ source = "photos", url-prefix = "/gallery" }]
[modules.resize-images]
git = { url = "https://github.com/tola-rs/modules.git", subdir = "resize-images" }
[modules.resize-images.options]
include = ["photos/**"]
exclude = ["photos/drafts/**"]
widths = [480, 960] # Also supports format = "webp"|"png"|"jpg", quality, upscale, jobs, dev
[modules.resize-images.options.overrides."photos/cover.jpg"]
widths = [1200]Reference outputs with output-url("images/<alias>/<asset-source>/w<width>.<ext>"), such as output-url("images/resize-images/photos/cover.jpg/w1200.webp"). Set source = { module = "notes" } to process another module’s assets.
Option merging
Defaults from the module’s [options] merge recursively with [modules.<alias>.options] in tola.toml: tables merge by key while scalars and arrays replace earlier values. Site-wide custom data lives under top-level [options], accessible as site.options in Typst and (get-site).options in Nu.
Customizing themes
Customize external themes without modifying their source files by layering overrides from lightest to deepest:
- Override
[modules.<alias>.options]flags and copy; if the theme exposesextra-styles, declare your stylesheet under[assets]and pass its path. - Replace specific theme asset URLs with
[modules.<alias>.assets.replace](or disable all module assets withenable = false); override module icon sets under[modules.<alias>.icons.collections.<name>]:
[modules.notes.assets.replace]
"theme.css" = "styles/custom-theme.css"- For structural layout changes, point
[build].entryback to your site’s"site.typ", import the theme’s render helpers, and pass custom layout callbacks:
#import "@tola-modules/notes:0.0.0": article, render-site
#let article-with-banner(source) = [
#html.aside(class: "notice")[Work in progress.]
#article(source)
]
#render-site(article: article-with-banner)