Duplication
Edit a block once, for example the site footer, and have it copied, verbatim, onto every page that references it. One master, many copies, kept in step on every run.
<!-- sitehoster:duplicate name="footer" role="master"
NOTE: Master copy of the site footer — edit here.
See: https://sitehoster.org/usage/automation/duplication/ -->
<footer>
… your footer …
</footer>
<!-- sitehoster:/duplicate name="footer" -->
Attributes
A duplication is a paired block, an opening sitehoster:duplicate comment and a
matching close, wrapped around the content. Its role is set on the opening comment, and a
free-text note after it reminds editors what the block is:
| Name | Type | Description |
|---|---|---|
name | required | ties a master to its copies; use different names for independent blocks (a footer, a banner, a sign-up box) |
role | master or copy | whether this block is the source you edit or a generated copy |
Copies
On every other page, the same markers with role="copy". Whatever sits between them
is replaced with the master’s content 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
See: https://sitehoster.org/usage/automation/duplication/ -->
<footer>
… replaced from the master …
</footer>
<!-- sitehoster:/duplicate name="footer" -->
There must be exactly one master per name within a site or group, and a copy with no master is an error. In a group a master and its copies are shared across every member: define the block once, on any site, and it fills the copies on all of them.
node client/automate.js (add --dry-run -v to preview).Errors
A duplication is validated before the site is written; a problem is reported against the page and the block, and the site is left unchanged until it is fixed (other sites still run):
| Message | When it appears |
|---|---|
sitehoster:duplicate "…" must set role="master" or role="copy" | an opening duplicate with no role, or an unknown one |
a second master for duplicate "…" (already defined in …) | two masters share one name within a site or group |
copy duplicate "…" has no master in group "…" | a role="copy" block whose name has no master anywhere in the group |