This document is relevant for people building or shipping a new MyST web theme (similar to the React/Remix apps behind book-theme, article-theme, etc).
It describes what the MyST engine expects today, with links to relevant source code.
The JTeX documentation remains the most complete reference for shared template metadata.
Architecture in brief¶
The MyST engine runs the content pipeline, while the theme is a web server that renders that content. Specifically:
When you run
myst start, the engine builds_build/site(content JSON, config, assets), serves it onCONTENT_CDN_PORT, and launches your theme with the template’sbuild.startcommand.A theme should read
_build/site/config.jsonfirst, fetch page JSON from/content/{slug}.json, and serve the app onPORT(Remix/Vite/Next-style).
Live reloads are facilitated by a websocket endpoint at /socket, which processes JSON messages. Static assets, and template options with type file are copied into _build/site/public and served from /.
Theme metadata (template.yml)¶
Your
template.ymlmust declaremyst: v1andkind: site, plus human metadata liketitle,description,version,license,authors,tags,source/github, andthumbnail(see validators.ts).Static assets used by the theme should be listed in
files, and the main compiled entry can override the default astemplate(optional; defaults totemplatein the archive); both must exist in the archive and are copied alongside the build.tagsare surfaced by the templates API for discovery but are not consumed by the engine; use them to help users find your theme and filter, for example:myst templates list --site --tag arxiv.Runtime hooks live in
build:installruns once before start (defaults tonpm install), andstartruns your theme with the content server available (defaults tonpm run start; see template.ts).User options live in
options/parts/doc(defined in types.ts);fileoptions are copied into_build/site/publicbefore being handed to the theme (see manifest.ts).
For shared template.yml fields (common to all MyST templates), see the JTeX template metadata docs.
See the book theme template.yml for a detailed example.
Engine and theme APIs¶
During myst start the engine resolves/downloads your template (default book-theme), validates it as a site template, and installs dependencies if needed (template.ts).
It then produces _build/site/config.json, validates it against your doc/options, and copies any file options into _build/site/public (manifest.ts).
/content/{slug}.jsonpayloads (see crossReferences.ts); when the browser requests/slug, your theme should fetch/content/{slug}.json./config.json(see types.ts)./content/{slug}.jsonpayloads (see crossReferences.ts); when the browser requests/slug, your theme should fetch/content/{slug}.json(and/content/index.jsonfor/).Reference and search files at
/objects.inv,/myst.xref.json,/myst.search.json.Static assets from
/and a/socketwebsocket forLOGandRELOADevents. Your start script receivesHOST,CONTENT_CDN_PORT,PORT,MODE(set tostaticformyst build --html), and optionalBASE_URL; any framework or server is fine as long as it reads these and fetches content from the endpoints above.
Building HTML¶
When you run myst build --html, the CLI starts your theme with MODE=static. If your theme supports static exports, it should write HTML build artifacts that the CLI can collect and bundle into _build/html. Only one theme can create HTML output at a time; this may change.
Register your theme¶
Package the built theme so the archive root contains
template.yml, compiled assets, and any files listed infiles/template(see download.ts).Publish that bundle to a stable zip or git URL and add it to the
myst-templates/templatesindex withkind: siteand alinks.downloadentry; the MyST API (https://api.mystmd.org/templates/site/...) serves that metadata to the CLI when resolving themes (also in download.ts).Test registration by calling the API (
GET https://api.mystmd.org/templates/site), listing it in the CLI (myst templates list <id> --site), or by pointingsite.templateat your name or path and runningmyst startormyst build --site.