Typsite Documentation
Typsite Documentation
1 Introduction
Typsite is a tool for building static websites. It uses pure Typst to write content and processes it through Typsite to generate a fully functional static site.
2 Features
- Standard Typst expressions
- Framework support: hierarchical headings, section templates, sidebar, footer
- Rich text: paragraphs, sections, quotes, code blocks, math formulas, footnotes, page embedding
- Supports modern web standards such as HTML5, CSS3, and JavaScript (ES6+)
- Incremental compilation and real-time preview
3
Introduction to Typst
[/en/typst]
Typst is a modern typesetting system, similar to LaTeX, but designed to be more concise and easier to learn. It is primarily used to create beautifully typeset documents such as academic papers, books, and reports.
You can find the official English documentation here: Typst Document
For a Chinese tutorial on Typst, I highly recommend: The Typst Blue Book
(Oh my, the author is clearly aware that they're explaining an ontology!).
Typst
🔥has risen!🔥
🚀Did the TeX folks miss the memo?🚀
The rest of this section will introduce Typst & HTML → Typsite
3.1 Typst’s HTML Export Feature
In version
0.13
0.13
, Typst added HTML export capabilities, including an html-export mode and two core functions:
html.elem
html.elem
and
html.frame
html.frame
— using these, we can write Typst documents targeting HTML+CSS output.
3.2 Typsite: A Static Site Generator Based on Typst
Inspired by this, I developed a static site generator in Rust called Typsite.
Currently, Typst’s HTML export:
- Has good support for basic rich text
- Requires users to manually write complex styles using the
html.elem
html.elem
function - Cannot automatically convert all Typst ecosystem content into HTML
- For content with complex Typst styles,
html.frame
html.frame
can be used to convert them into SVG and embed them into HTML - Only supports single-file HTML output per compilation
For details on supported features and the roadmap, follow this issue: HTML export #5512
Although the official team plans to support automatic typst style → HTML+CSS in the future, this won’t conflict with Typsite. On the contrary, Typst’s development will make Typsite even more useful, because Typsite’s main role is to coordinate interaction between articles and ultimately build a fully functional static website.
4 Installation
-
Download the binary from the release
- Make sure you have Typst 0.13+ installed
-
Build via Nix & Flakes
- Ensure you’ve enabled
experimental-features = nix-command flakes
experimental-features = nix-command flakes
- Ensure you’ve enabled
git clone https://github.com/Glomzzz/typsite.git
cd typsite
nix build .
git clone https://github.com/Glomzzz/typsite.git
cd typsite
nix build .
5 Initialization
Run
typsite init
typsite init
to initialize a Typsite project in the current directory.
.
├── root --- Typst root directory
│ ├── index.typ --- Main article
│ └── lib.typ --- Typsite library file
├── .typsite --- Typsite configuration directory
│ ├── assets --- Resources (synced to output directory)
│ ├── components --- Component templates
│ ├── themes --- Code highlighting themes
│ ├── rewrite --- Rewrite templates
│ ├── schemas --- Page templates
│ └── options.toml --- Project configuration
├── .cache --- Cache directory
└── publish --- Output directory
.
├── root --- Typst root directory
│ ├── index.typ --- Main article
│ └── lib.typ --- Typsite library file
├── .typsite --- Typsite configuration directory
│ ├── assets --- Resources (synced to output directory)
│ ├── components --- Component templates
│ ├── themes --- Code highlighting themes
│ ├── rewrite --- Rewrite templates
│ ├── schemas --- Page templates
│ └── options.toml --- Project configuration
├── .cache --- Cache directory
└── publish --- Output directory
7 CLI (Command Line Interface)
Usage: typsite <COMMAND>
Commands:
init Initialize a new Typsite project in the specified directory
compile Compile or watch a project; specify input/output [alias: c]
clean Clear cache and output directories
help Print this message or help info for a subcommand
Options:
-h, --help Print help
-V, --version Print version info
Usage: typsite <COMMAND>
Commands:
init Initialize a new Typsite project in the specified directory
compile Compile or watch a project; specify input/output [alias: c]
clean Clear cache and output directories
help Print this message or help info for a subcommand
Options:
-h, --help Print help
-V, --version Print version info
7.1 init
Initialize a new Typsite project in the specified directory
Usage: typsite init [OPTIONS]
Options:
-d, --dir <DIR> Project root directory [default: ./]
-h, --help Print help
Initialize a new Typsite project in the specified directory
Usage: typsite init [OPTIONS]
Options:
-d, --dir <DIR> Project root directory [default: ./]
-h, --help Print help
7.2 compile
Compile or watch the project, specifying input/output directories
Usage: typsite compile [OPTIONS]
Options:
--port <PORT> Server port [default: 0]
--config <CONFIG> Config path [default: ./.typsite]
--cache <CACHE> Cache directory [default: ./.cache]
-i, --input <INPUT> Typst root directory [default: ./root] [alias: --i]
-o, --output <OUTPUT> Output directory [default: ./publish] [alias: --o]
--no-pretty-url
--no-short-slug
-h, --help Print help
Compile or watch the project, specifying input/output directories
Usage: typsite compile [OPTIONS]
Options:
--port <PORT> Server port [default: 0]
--config <CONFIG> Config path [default: ./.typsite]
--cache <CACHE> Cache directory [default: ./.cache]
-i, --input <INPUT> Typst root directory [default: ./root] [alias: --i]
-o, --output <OUTPUT> Output directory [default: ./publish] [alias: --o]
--no-pretty-url
--no-short-slug
-h, --help Print help
7.3 clean
Clear cache and output directories
Usage: typsite clean [OPTIONS]
Options:
-o, --output <OUTPUT> Output directory [default: ./publish]
-c, --cache <CACHE> Cache directory for typst_html_export content [default: ./.cache]
-h, --help Print help
Clear cache and output directories
Usage: typsite clean [OPTIONS]
Options:
-o, --output <OUTPUT> Output directory [default: ./publish]
-c, --cache <CACHE> Cache directory for typst_html_export content [default: ./.cache]
-h, --help Print help
7.4 syntect
View the list of syntax highlighting and supported languages
Usage: typsite syntect [OPTIONS]
Options:
--config <CONFIG> Config path [default: ./.typsite]
-h, --help Print help
View the list of syntax highlighting and supported languages
Usage: typsite syntect [OPTIONS]
Options:
--config <CONFIG> Config path [default: ./.typsite]
-h, --help Print help
8 Architecture & Flow
9 Configuration
You can view all default configurations here:
Based on these, you can fully customize your entire site.
- schema: Page templates, handling page structure
- components / rewrites: Components/Rewriters, build up the page content
- assets: Resource files, automatically synced during compilation
- themes: Code highlighting files
- syntaxes: Code syntaxes files