How it works
- Load the steering config from
<dir>/site.config.mjs. - Resolve the theme. A
file:or path reference is used directly. A git reference is downloaded as a tarball fromcodeload.github.comand extracted into the cache. No git binary is needed. - Find the Astro project in the theme, using
remote-theme.json(astroRoot, defaultastro), and runnpm installthere ifnode_modulesis missing. - Link your files into the theme.
<dir>/contentis symlinked to the theme’scontentLink, and<dir>/assetsto itsassetsLink. Symlinks keep module resolution anchored inside the theme, so bare imports in your content files resolve against the theme’s dependencies. - Write the generated config to
<astroRoot>/.remote-theme/site-config.generated.mjs: your steering config withouttheme, pluscontentRoot. - Run the theme’s own
astrobinary withREMOTE_THEME_SITE_CONFIGandREMOTE_THEME_OUT_DIRset. - For
build, copy the output todist/in your repo. Astro builds next to the theme first because it moves files withrename(), which fails across filesystems.
The cached content-layer file (node_modules/.astro/data-store.json) is cleared on each run so changed link locations never leave stale paths behind.
Theme manifest
Section titled “Theme manifest”A theme can declare remote-theme.json at its root:
| Key | Default | Meaning |
|---|---|---|
astroRoot | astro | Astro project folder inside the theme. |
contentLink | .remote-theme/content | Where the content folder is symlinked. |
assetsLink | src/assets/remote | Where the assets folder is symlinked. |
What the theme must do
Section titled “What the theme must do”- Read the config at
process.env.REMOTE_THEME_SITE_CONFIG. - Use
process.env.REMOTE_THEME_OUT_DIRasoutDir. - Set
vite.resolve.preserveSymlinks: true. - Load content from the
contentRootgiven in the generated config.
mom-doc-theme is the reference implementation.
Trust model
Section titled “Trust model”Building a theme runs its code and its dependencies’ install scripts. Treat a theme reference like any other dependency: pin a tag or SHA you trust.