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:

toml
[build]
entry = { module = "notes" }

[modules.notes]
path = "theme"

[modules.notes.options]
show-title = true
toml
[modules.theme]
git = { url = "https://github.com/example/tola-theme.git", tag = "v1.0.0", subdir = "dist/theme" }
toml
[modules.theme]
tarball = { url = "https://example.com/theme-v1.0.0.tar.gz", sha256 = "0123..." }
  • path: resolves relative to tola.toml (must stay inside the site directory under --pure).
  • git: specify at most one of tag, branch, or full rev (defaults to the remote default branch), plus optional subdir. HTTPS uses Git credential helpers; SSH uses your local SSH config.
  • tarball: accepts url or local path in .tar.gz, .tar.zst, or .zip format with optional 64-hex sha256. Archives must have one top-level directory containing tola-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:

toml
[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):

toml
[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:

  1. Override [modules.<alias>.options] flags and copy; if the theme exposes extra-styles, declare your stylesheet under [assets] and pass its path.
  2. Replace specific theme asset URLs with [modules.<alias>.assets.replace] (or disable all module assets with enable = false); override module icon sets under [modules.<alias>.icons.collections.<name>]:
toml
[modules.notes.assets.replace]
"theme.css" = "styles/custom-theme.css"
  1. For structural layout changes, point [build].entry back to your site’s "site.typ", import the theme’s render helpers, and pass custom layout callbacks:
typst
#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)

Search this site

Use the arrow keys to move through results.

Type to search.