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 is a third script, alongside the sync client and the log mirror, client/automate.js. It reads the same config.json (it only needs contentRoot, your folder of site folders) and, like the others, runs once or on a timer:

node client/automate.js                  # one pass over every site
node client/automate.js --dry-run -v     # show what would change, write nothing
node client/automate.js --watch          # keep running (default every 60s)
node client/automate.js --watch --interval 30

Three rules keep it safe to run at any time: it is localised per site (a master in one site can never be referenced from another), strict per site (each site is validated on its own; any malformed marker leaves that site 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: records on each page feed listings and counts elsewhere, filled from templates and kept in step.

Data →

Example

Every kind of automation is a pair of HTML comments beginning with localhoster:, an opening directive and a matching close, wrapped around a block. Take duplication: the master is the one copy you edit,

<!-- localhoster:duplicate name="footer" role="master"
     NOTE: Master copy of the site footer — edit here. -->
<footer>
  … your footer …
</footer>
<!-- localhoster:/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:

<!-- localhoster:duplicate name="footer" role="copy"
     NOTE: Generated — edit the master at: /index.html -->
<footer>
  … replaced from the master …
</footer>
<!-- localhoster:/duplicate name="footer" -->
Note: the notes are free text to remind editors about the structure.