
How I scaffold my typst documents
Just wanted to share the way I manage my typst documents. Basically, I love using typst just to write documents in general, like, instead of using Google Docs, Word, whatever ...
I wanted a system in order to re-use my templates without copy pasting whatever previous typst project I had, then "remaking" it into my new document.
So I took some inspiration for how shadcn works: one just scaffolds the thing. Like, instead of having it as some kind of dependency in some package system, you have all the stuff as "first class code".
So the idea is through github to just have a sh file that one can curl and execute, then it just scaffolds a template for me. The project template is designed to be fully reproducible, so it will include font files as well.
Link to repo:
https://github.com/Napam/typst-templates
Just wanted to share this in case this scaffolding pattern may be useful for others!
EDIT:
Just want to elaborate more on the motivation behind this (copy pasted from a comment):
One of my motivations was to minimize system setup and have better reproducability.
One could have templates as packages in $XDG_DATA_HOME/typst/packages in order to have globally re-usable templates that one can tweak on.
Issue with that is:
- If one updates the global templates, old documents may change on recompilation, and it requires one to set up the templates in the environment.
- More font handling to manage. E.g. you have a font available on a laptop (say, Mac), then you want to re-compile on your Linux desktop, then you may not have the font you used on your mac.
What I wanted for my typst document-projects:
- Just a dir with fonts, all the required typst code, and a justfile for convenience. The "document" is entirely self contained, and will should look the same (assuming typst doesn't suddenly change a lot in how they render in newer versions)