Rewrite it (the Blog) in Typst
Published
If you know me online or in real life, it has been impossible to miss how excited about Typst I am. I felt motivated to write about Typst on a few occasions, but the prospect of writing about that new typesetting system not using Typst tempered that motivation quite a bit… Well, that excuse won't work anymore, since this blog is now Typst-based!
I like to describe Typst like this: "imagine you had a typesetting system as powerful as LaTeX, but writing felt like Markdown and scripting felt like Python (or better, actually)." That may not exactly sound like a technology for creating HTML content, but that is currently changing: Typst now has experimental HTML export, and projects like shiroa, typst.ts, or astro-typst are already building on that early support to enable actual websites. A big shoutout to their creators!
The ingredients
Let's lay out what major pieces of software are involved:
- Astro for the web and content management aspects
- Tailwind for some light styling
- astro-typst for integrating Typst into the thing
- zebraw for code syntax highlighting in HTML
To start off, I used Astro's official blog template, a well-structured, minimal template that I trusted to have sensible defaults for things I didn't want to spend much time on – performance tweaks, SEO and so on. I then scanned Myriad-Dreamin's tylant, an Astro template that integrates Typst, for the relevant parts and adapted them to my needs. For example, that template gets some Typst code from a git submodule, which I'm not a fan of, so I got rid of that peculiarity.
Most of the other work was then fairly mundane and not Typst specific: setting Astro up to find blog posts and offer them under my preferred URL scheme (/2025/06/29/rewrite-it-in-typst
), adding Tailwind and recreating/re-applying the existing styles, and setting up automatic deployment.
There were however a few tweaks that I think may be interesting for people going in a similar direction:
Conditional styling for non-HTML preview
One of the nice things about Typst is that it has instant preview; when you add a whole web app to that mix in the form of npm run dev
, that experience is highly degraded compared to simply using Tinymist! Even though the non-HTML appearance of a blog post doesn't matter in the end, it's nice to see what you're writing in a bit more detail.
So I created a tiny "template" that blog posts would be based on, to add some of the content that is rendered by Astro in the final product:
Syntax highlighting in HTML-exported code snippets
One thing I seem to have missed while migrating adaptations from the tylant template was rendering of code blocks. Fortunately it wasn't hard to track down the critical settings in shiroa and adapt them for myself:
Rendering an excerpt manually from Typst source code
The final puzzle piece (so far) was rendering an excerpt or blurb on overview pages; the text would be defined as part of the post's front matter and passed to Astro as Typst source code:
My first attempt on this was using astro-typst as a component:
However, this turned out to generate <html>
tags etc. too, making the final markup invalid. It took a bit of searching, but the necessary functions for extracting just the body are also available in astro-typst:
Conclusion
I'm sure I will stumble over other things that still need some adaptation – for example, I haven't tried adding images or math formulas yet – but considering that Typst's HTML support is still experimental, this project (and others) have been a fairly smooth experience! This is of course thanks to both the Typst team and the Typst community; in this case chiefly Myriad-Dreamin, who as the maintainer of Tinymist, typst.ts and shiroa is a real powerhouse!
I hope setting this foundation will motivate me to write more here, be it about Typst or other topics.