Automation
Take the repetitive work out of authoring a static site. Automation works by leaving special HTML comments in your pages that mark a block as a master (the one source of truth) or a copy (a generated copy). A small script reads them and rewrites the copies to match, so shared content stays in step across a site, with no build framework.
Running
Automation runs as the first half of a sync:
sitehoster-local.js --config <path> --sync rewrites every copy from its master and then
pushes, so un-automated content is never published. To run just the automation pass, the compiler ships in
the package at sitehoster-sync/lib/automate.js and reads the same config (it only needs
sitehoster-config-contentRoot, your folder of site folders):
node sitehoster-local.js --config /path/to/config.json --sync # automate every site, then push
node sitehoster-sync/lib/automate.js --config /path/to/config.json # one automation pass, no push
node sitehoster-sync/lib/automate.js --config /path/to/config.json --dry-run -v # show what would change, write nothing
Three rules keep it safe to run at any time: it is localised per group (masters and records are shared within a group of sites but never across groups, and a lone site is a group of one), strict per group (each group is validated on its own; any malformed marker leaves that group unchanged but never blocks the others), and mtime-safe (a file is only rewritten when its bytes actually change).
Capabilities
Each kind of automation is marked up the same way, a master block and its copies, but does a different job:
Duplication
Edit a block once, for example the site footer, and have it copied, verbatim, onto every page.
Duplication →Navigation
A navigation is duplicated like any block, with one extra step: each copy highlights the item for the page it sits on.
Navigation →Data
Your pages are a database: each page carries a record, and other pages pull those into listings and counts, filled from templates and kept in step.
Records →Grouping
Put related sites in one folder and they share all of the above: one footer, one menu and merged data across a set of subdomains or separate domains.
Grouping →Example
Every kind of automation is a pair of HTML comments beginning with sitehoster:, an
opening directive and a matching close, wrapped around a block. Take duplication: the
master is the one copy you edit,
<!-- sitehoster:duplicate name="footer" role="master"
NOTE: Master copy of the site footer — edit here. -->
<footer>
… your footer …
</footer>
<!-- sitehoster:/duplicate name="footer" -->
and a copy is the same markers with role="copy" on any other page.
Whatever sits between them is replaced from the master on the next run, and the note points back to
where the master lives:
<!-- sitehoster:duplicate name="footer" role="copy"
NOTE: Generated — edit the master at: /index.html -->
<footer>
… replaced from the master …
</footer>
<!-- sitehoster:/duplicate name="footer" -->