Skip to content

The local site

Terminal window
t4 mirror # uses the environment's published_url
t4 mirror https://webtest.example.edu/
t4 serve # http://127.0.0.1:8321/

The mirror crawls the published site over HTTP. It is a separate thing from t4 pull, which reads layout source from the CMS API, so it needs the published host to be reachable, which behind a campus network means the VPN. Once the mirror is on disk, t4 serve needs nothing but the files (and --proxy, if you left assets unmirrored).

t4 serve sets up what it needs. If there is no mirror yet it fetches one from the environment’s published_url before serving, so a fresh checkout is t4 serve rather than t4 mirror then t4 serve. That first fetch needs the published site to be reachable; afterwards everything is served from disk. --no-setup makes it fail instead, and --setup-limit N caps the first crawl.

t4 serve watches both t4-source/ and overrides/ and refreshes the browser on save, via an injected server-sent-events listener. --no-reload turns it off. Responses are sent Cache-Control: no-store, so a plain reload picks up edits.

One file to edit, and it is the one that deploys. A site’s CSS and JS are Media Library items whose content T4 serves verbatim, so the file pulled into t4-source/<env>/media/ is the same bytes the site publishes. t4 serve serves that file in place of the mirrored copy:

Terminal window
t4 serve
# edit t4-source/<env>/media/site.css -> the browser reloads
t4 diff media/site.css -> shows the change
t4 push media/site.css -> deploys it

No second copy to keep in step, and no manual upload. --no-media-source turns this off if you want the mirror served as it is.

Edits to page layouts and content layouts show up too; see Layout previews.

The mirror saves files verbatim. They are byte-identical to what T4 published, so markup copied out of them pastes straight back into a layout. URL rewriting happens at serve time instead.

Rules for your own channels are derived automatically from the published_url of each configured environment. T4 writes absolute URLs into published pages, and they usually point at production even in a test channel: hosts that are typically unreachable from a workstation. Without rewriting them the stylesheets never arrive and the page renders unstyled, which looks like a rendering fault rather than a missing asset.

Add anything else to .t4/rewrites.conf; file rules are applied before the derived ones:

# <regex><TAB><replacement>
https?://legacy\.example\.edu/ /

Documents (PDF, Office) are skipped by default; --include-documents keeps them. If a firewall or rate limiter blocks the crawl, --delay pauses between requests.

Anything missing locally is fetched from the live site on demand and cached, like Drupal’s stage_file_proxy. Images and documents dominate a mirror’s size while contributing nothing to front-end work, so you can mirror pages, CSS and JS and still see a complete site.

Terminal window
t4 serve # proxies to the environment's published_url
t4 serve --proxy https://www.example.edu
t4 serve --no-proxy # serve only what is mirrored
t4 serve --no-proxy-cache # proxy without writing into the mirror

The proxy saves each image it fetches, so whatever you have looked at while connected is there next time. To have every image before you go offline:

Terminal window
t4 mirror --images

It reads the pages already in the mirror, finds every image they use (<img>, srcset, inline style backgrounds and stylesheets) and downloads the ones that are not on disk. It does not crawl the pages again, so it also completes a mirror that --limit stopped early. Running it again fetches only what is still missing. Images named with the site’s other addresses, such as production’s in a test channel, are fetched from the mirrored host, the same way t4 serve serves them. In the app, this is Download images.

t4 edit is for the rest: a mirrored page, a third-party script, anything the pull does not cover and you want to experiment on locally. It copies the file into overrides/ at the right path so you do not have to reproduce a deep one by hand. --list shows what is overridden, --revert drops one, and a wrong path suggests near matches.

Overrides are local-only and are never deployed. CSS and JS do not belong here: they are Media Library items served straight from t4-source/, so you edit those directly and they deploy.

t4 edit refuses to override something that has been pulled, and points at the pulled file instead. An override of a pulled file is a second copy that serves identically and silently never deploys. You can lose an afternoon to it while the browser shows your change the whole time. If you already have one:

Terminal window
t4 edit --promote media/web/b3/css/site.css # move it into the source, drop the copy

t4 serve also reports any override that shadows pulled source at startup, since refusing to make new ones does not find the ones already there.

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.