Thanks for typst team and @azure lodge, @timid yoke, @split pulsar, we have a very happy experience on building a static website using typst 0.13.0's HTML export. We hadn't had any frustrating problem and everything goes smooth. Impressively, for example, although typst doesn't have support to export math equations to HTML, we can support it on our side with an oneline show rule:
#let div-frame(content, attrs: (:)) = html.elem("div", html.frame(content), attrs: attrs)
show math.equation: div-frame.with(attrs: ("style": "display: flex; justify-content: center; overflow-x: auto;"))
Using 84.3% Typst, 2.3% CSS, and 0.9% HTML, it even doesn't use any static site generator or bundler, but a simple build script that calls typst compile and typst query.
What's the input:
assetsare fonts, styles, icons, andtmThemefiles used by the typst compiler.typ/packagesare local packages.typ/templatesare common template and components.src/are common source code used by documents.content/{zh-CN, en}are documents in specific languages.
How it builds the site:
npm installto install the compiler, no any other external software and packages are required.npm run build: build the output once.npm run build -- --url-base=/news/: build the output once to host onmy.github.io/news/npm run dev: watch the whole project.npm run serve: starts a local http server for preview.
To add a new content (news):
Create a typst file under the content/en/news/date/ containing the tempalte initialization:
#import "/typ/templates/news.typ": *
#show: news-template.with(
date: "2025-02-06",
title: "Typst 0.13.0, RC 1 released",
lang: "en",
tags: ("update",),
description: "Typst 0.13.0, RC 1 was released.",
)
Other translated files can be optionally created.
Website: https://typst-doc-cn.github.io/news