hooks
Build pipeline
When moss compiles a site, it runs through these stages in order:
Scan folder
→ process hooks (pre-generation)
→ generate hook (build HTML)
→ enhance hooks (inject into slots)
→ deploy hook (push to hosting)
→ syndicate hooks (POSSE to platforms)
Plugins attach to stages by declaring capabilities in their manifest.
Hook reference
| Hook | Arity | Context | Description |
|---|---|---|---|
process | multiple | ProcessContext | Pre-process source files before generation (e.g. download remote assets, transform markdown). |
generate | single | GenerateContext | Build/transform source files to HTML output, replacing the default moss build pipeline. |
enhance | multiple | EnhanceContext | Provide HTML for named template slots after generation (head-end, footer-end, after-article, etc.). |
deploy | single | DeployContext | Deploy the built site to a hosting platform (e.g. GitHub Pages, Netlify). |
syndicate | multiple | SyndicateContext | POSSE-distribute published content after deployment (e.g. cross-post to Matters, RSS). |
import | multiple | ProcessContext | Import content from an external source into the project folder (e.g. Matters profile, RSS feed). |
process
Runs before HTML generation. Multiple plugins can have this capability.
Use for: fetching external data, transforming source files, pre-processing content.
Context passed to the hook:
| Field | Type | Description |
|---|---|---|
project_path | string | Absolute path to the project folder |
moss_dir | string | Path to .moss/ directory |
project_info | object | total_files, homepage_file, site_name, lang |
config | object | Plugin configuration values |
Data contract: A process hook that fetches external data writes JSON to .moss/data/social/<plugin>.json. The build core does not read this file; enhance hooks and other plugins consume it.
The generated source-to-output map (paths plus uids) is at .moss/build/article-map.json.
generate
Builds or transforms source content into HTML output. Only one plugin can have this capability; it replaces moss's built-in generator.
Use for: alternative SSG backends (Hugo, Astro, Jekyll).
Context: Same as process, plus output_dir, source_files (categorized by type), and site_config.
enhance
Injects content into named template slots after HTML is generated. Multiple plugins can have this capability.
Use for: comments, analytics, newsletter forms, custom scripts.
Template slots
Slots are named injection points in the HTML template where plugins can insert content.
| Slot | Position | Authorable |
|---|---|---|
head-end | Before — for stylesheets, scripts, and meta tags. | no |
after-title | Inside | no |
before-article-end | Inside | no |
after-article | Between and — for comments, reactions (NOT part of the article). | no |
footer-shape | The data-moss-shape attribute value on the | no |
footer-left | Inside footer, leading position — filled by footer.md or any file with slot: footer-left frontmatter. | yes |
footer-end | Inside footer, trailing position — for the auto-injected subscribe form and plugin widgets. | no |
body-end | Before |