Skip to content

Layout previews

Edits to a pulled page layout show up on the local site without a publish cycle:

Terminal window
t4 serve
# edit t4-source/<env>/pageLayout/<name>.footer.html
# reload: the change is there

This is not rendering. T4 tags are evaluated by T4, and nothing local can run them. But the mirrored page is the result of running them, so the two can be aligned:

source: <lit A> <t4 .../> <lit B> <t4 .../> <lit C>
output: <lit A> ...????.. <lit B> ...????.. <lit C>

The literal markup appears verbatim in the published page, so whatever sits between those anchors is what the tags produced. Capture it, then re-emit the edited source with it substituted back. Wrapping a tag in a div, changing a class, adding or reordering markup: all apply locally.

A no-op edit reproduces the page byte-for-byte; that invariant is tested.

Or without a browser:

Terminal window
t4 preview # the home page
t4 preview about/admissions
t4 preview --out /tmp/x.html # write the previewed HTML instead
index.html
layout standard #1180
edited pageLayout/standard.footer.html
--- published
+++ with local edits
<!-- n:Footer-Contact (273) -->
<div class="footer-contact-bar-ts"><!-- n:Footer-Contact (273) -->

This is not a substitute for T4’s own Preview, which is authoritative. The REST API exposes no preview or publish operation (checked on 8.4.3 and 8.4.5), so seeing the rendered result still means previewing or publishing in T4.

Editing a content layout shows up too, applied to every item on the page that uses it: a page with twenty Contact items gets all twenty. Nothing is written into the mirror; the splice happens on the way out, so mirrored files stay byte-identical to what T4 published.

It needs t4 sections, because an edit is only applied inside the output of items of its own type. Without that check a short layout’s literal markup matches wherever it happens to occur, and a false match does not merely fail to help: it rewrites part of a page that layout never produced.

Where it cannot be faithful, it does nothing. A content layout renders once per item, and its optional fields are empty for some of them. A tag that produced no output cannot be told apart from any other that produced none, so re-emitting would drop real content: names, ids, links. Those occurrences are left exactly as published and the page says so in a comment. On a real site this lands for roughly half the occurrences: simple structural layouts preview, field-heavy ones like a staff profile do not.

A tag with no published output (a new tag, or an existing one pointed at a different id) has never produced anything to reuse:

<!-- T4 PREVIEW: <t4 type="navigation" id="99" /> has no published output to
reuse, so it cannot be previewed -->

For a new tag, use sample data instead.

Tags whose output cannot be told apart. Where several tags sit together with no literal markup between them, their output is one undivided run. If the site’s layouts bracket a tag’s output with comments, that tag can be isolated (the defaults recognize <!-- n:Name (ID) -->…<!-- /n:ID --> and the ct: equivalent; set span_markers in .t4/config.json for other conventions). Otherwise, placing markup around one tag of the run would silently wrap all of them, so it says so:

<!-- WARNING: markup was placed around tags whose individual output cannot be separated -->
<!-- affected: <t4 type="navigation" id="276" />, <t4 type="media" id="1094476" ... -->
<!-- what you see wraps the whole run, which is not what T4 will publish -->

That warning is the point. A preview that quietly differs from what T4 will publish is worse than no preview.

--no-preview serves the mirror exactly as published.

An independent, unofficial tool. Not produced, endorsed or supported by TERMINALFOUR Solutions Ltd, and not TERMINALFOUR software. “T4” and “TERMINALFOUR” are their trademarks, used here only to identify the software this works with. Copyright © 2026 Small Robot Corp. Source available under the PolyForm Shield License 1.0.0.