[hooks]
Run Nu scripts or external commands before discovery, after compilation, or after publication.
Stages
| Stage | Purpose |
|---|---|
[[hooks.before-build]] | Generate Typst pages, templates, data files, or static inputs before content discovery. |
[[hooks.generate-outputs]] | Produce additional publishable files (such as search indexes) from compiled outputs. |
[[hooks.after-publish]] | Inspect or deploy the published site directory after files are written. |
Execution order and concurrency
Each hook runs either a bundled-runtime Nu script (nu with optional args) or an external executable (argv), with the site root as its working directory.
- Within one stage and one site or module instance, hooks run in ascending
order(default0). Hooks sharing the sameordermay run in parallel; configure concurrency withbuild.par-hooksandbuild.hook-jobsin[build]. - Across instances, modules run in alphabetical alias order.
before-buildruns site hooks before module hooks;generate-outputsandafter-publishrun module hooks first. If a batch fails, later batches are skipped. - All
generate-outputshooks read the same compiled snapshot; combine dependent steps into one script if one needs another’s output.
Command matrix
| Command | Mode | before-build | generate-outputs | after-publish |
|---|---|---|---|---|
tola build | prod | Run | Run | Run |
tola check | prod | Run | Run | Skip |
tola preview | prod | Run | Run | Skip |
tola dev | dev | Per dev | Per dev | Per dev |
tola inspect / vendor | — | Skip | Skip | Skip |
Pass --no-hooks to tola check to skip build hooks and reuse existing generated inputs. Run tola inspect config --mode prod --json --pretty (or --mode dev) to inspect resolved hook batches and skip reasons.
Context, diagnostics, and watching
- Read stage paths and options via
use tola get-contextin Nu or@tola-scripts/contextfrom external commands.TMPDIR/TMP/TEMPpoint to a freshhook.tempDirper run; persistent state belongs inhook.cacheDir. - Submit warnings or errors with
use tola diagnostic(diagnostic submit) or write JSON toreportPath(see@tola-scripts/diagnostic). - Tola automatically watches the
nuentry script. List extra input files inrerun-on = { include = [...], exclude = [...] }. In Nu hooks,use tola get-hook; get-hook --rerun-on-digestreturns a content digest of trackedrerun-oninputs for custom cache keys.
Subtables
| Section | Summary |
|---|---|
[[hooks.before-build]] | Run commands before content discovery to generate Typst sources, data, or static inputs. |
[[hooks.generate-outputs]] | Produce additional publishable files—such as search indexes or manifests—from compiled outputs. |
[[hooks.after-publish]] | Run post-publish commands—such as deployment or HTML verification—against the published directory. |