Add spa flag for static deployments; fix Hugo navigation

Static (manager: caddy) deployments always emitted the SPA fallback
`try_files {path} /index.html`, which serves the root index.html for
every unmatched path. That's correct for React/Vite apps but swallows a
multi-page content site's in-page links back to the homepage, so a Hugo
site (payne.io) couldn't navigate off its landing page.

Add an explicit `spa: bool` on CaddyDeployment (default True, preserving
existing SPA behavior). When False, the gateway serves plain file_server
— resolving directory indexes (/posts/ -> /posts/index.html) and 404ing
missing paths. Threaded through the registry snapshot + mesh and the
route computation so both the internal wildcard and public apex blocks
honor it. `castle program create --stack hugo` now sets spa: false.
This commit is contained in:
2026-07-12 23:41:47 -07:00
parent 1767a0a304
commit d152e79cee
6 changed files with 58 additions and 24 deletions

View File

@@ -13,7 +13,12 @@ How to build, serve, and manage [Hugo](https://gohugo.io) sites as castle progra
- Generator: Hugo (extended recommended — needed for SCSS/asset processing)
- Build: `hugo --gc --minify``public/`
- Served: `manager: caddy` static deployment, in place at `<name>.<gateway.domain>`
- Served: `manager: caddy` static deployment, in place at `<name>.<gateway.domain>`,
with `spa: false` — the gateway resolves directory indexes (`/posts/`
`/posts/index.html`) and 404s missing paths. (The default `spa: true` is a
single-page-app fallback that serves the root `index.html` for every unmatched
path — correct for React/Vite, but it swallows a Hugo site's in-page links back
to the homepage. `castle program create --stack hugo` sets `spa: false` for you.)
- Package manager (only if a theme needs an asset pipeline): pnpm
Hugo has one meaningful dev verb — **build**. It has no native lint/test/type-check,