Phase 5 part 2: preview any branch of a site
Sites → Previews builds a branch with Hugo (drafts included) and serves it under /preview/<site>/<branch>/, links rewritten to stay inside, behind a sandboxing CSP so a branch's scripts can't act on the app or phone home. The image now builds Hugo v0.170.1 from source; Alpine's 0.147.2 couldn't build the site. Hugo's errors show their innermost cause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1262,6 +1262,24 @@ pages (`/sites`) reads the repository on request and shows the latest
|
||||
commits on the published branch. Live: federated-website has 25 section
|
||||
types and 59 pages (22 built from sections).
|
||||
|
||||
**Part 2 built (2026-11-22; no schema change).** Sites → Previews lists the
|
||||
repository's branches (the published one first) and builds any of them:
|
||||
a fresh read, the branch checked out, `hugo --buildDrafts --buildFuture`
|
||||
for `/`, then every root-relative address in the HTML and CSS rewritten to
|
||||
`/preview/<site>/<branch>/`. The copy goes back to the published branch
|
||||
afterwards. A failed build keeps serving the last good preview; a preview
|
||||
older than its branch says so. Previews are served with a CSP `sandbox`
|
||||
(no `allow-same-origin`): the site's scripts run, but each page has an
|
||||
opaque origin, so the guard refuses anything it posts to the app; it can't
|
||||
connect anywhere either, so analytics don't count previews. Folders show
|
||||
only through their index.html.
|
||||
|
||||
**The image's Hugo** was Alpine's 0.147.2, too old for federated-website
|
||||
(`hugo.Data` needs 0.156+), so even the SEO build check would have failed
|
||||
on it. The Dockerfile now builds Hugo v0.170.1 from source in a Go 1.27
|
||||
stage (the standard edition: sites needing Sass won't build). Hugo's
|
||||
errors now show the innermost cause, with paths cut to the repository's.
|
||||
|
||||
### Future enhancements
|
||||
|
||||
Not in any phase yet; picked up when the user asks.
|
||||
|
||||
Reference in New Issue
Block a user