Build model
Tola splits the build between the host binary and your Typst entry program: the host merges configuration, discovers sources, schedules hooks, collects static assets, checks the output graph, and publishes atomically; the entry program filters content, computes routes, renders pages, and declares Bundle assets.
Pipeline
- Prepare & discover: Merge
tola.toml,includefiles, and module manifests, runbefore-buildhooks, then scancontent-dirand read top-leveltola-meta. Becausebefore-buildruns first, generated.typfiles are discovered in the same build. - Compile & assemble: Compile
[build].entryas one Typst Bundle to emit everydocument(...),asset(...), and derived image/icon, gather[assets], and pass the snapshot togenerate-outputshooks. - Verify & publish: Combine all outputs into one graph and check output path uniqueness, internal links, asset references, and fragments.
checkandpreviewstop here;buildswapspublish-diratomically (removing deleted pages) and runsafter-publish.
Source discovery
[build].entry defaults to "site.typ" at the project root, or { module = "docs" } to delegate to a theme module’s build entry.
The entry calls all-sources() from @tola/source:0.0.0 to list sources under [build].content-dir (default content/):
- Only lowercase
.typfiles are collected, sorted deterministically by full source path. - Hidden files, hidden directories, symlinks, and the entry file itself are skipped automatically.
- Keep shared templates, styles, and helper modules outside
content/so they are not treated as pages.
#import "@tola/address:0.0.0": join-route, output-of
#import "@tola/source:0.0.0": all-sources
#for source in all-sources() {
let output = output-of(join-route(source.route-segments))
document(output, format: "html")[
#include source.file
]
}Because discovery runs before rendering and the entire site evaluates in one Bundle, the entry can filter drafts, sort pages, emit both HTML and format: "pdf" from one source, or generate extra archive, tag, and JSON index outputs outside the loop.
Build mode
site.build-mode in @tola/site:0.0.0 identifies the current command environment:
site.build-mode | Context |
|---|---|
"dev" | tola dev live development server. |
"prod" | tola build, tola check, tola preview. |
none | Non-build commands: tola lsp, tola query, tola inspect. |
#import "@tola/site:0.0.0": site
#let is-prod = site.build-mode == "prod"Split config
Large configs can pull in local TOML files via include at the top of tola.toml before the first [table] header:
include = [
"config/docs.toml",
"config/reference.toml",
{ path = "config/local.toml", optional = true },
]
[site]
title = "Tola"Paths inside include resolve relative to the declaring config file, while config values (such as static/... or tools/...) always resolve relative to the site root containing tola.toml. Files merge in order with the root tola.toml applied last: tables merge by key, scalars and plain arrays overwrite earlier values, and [assets] and [[hooks.*]] append in order. Run tola inspect config to verify the merged result.
Languages
Set language and languages = ["en", "zh-Hans"] under [site] to expose parsed locale records (tag, lang, script, region) through site.language and site.languages.