Build a static site
Produce a deployable `output/` directory by running the same app in build mode and reading the `BuildReport` for failures.
To turn a working Pennington site into a folder of static HTML for a static host, run the app in build mode. For why the same Program.cs works in both dev and build, see Dev mode and build mode share one code path; for platform-specific upload steps, see Deploy to GitHub Pages; for sub-path sites, see Host under a sub-path (base URL).
Before you begin
- A working Pennington site that serves under
dotnet run(see Create your first Pennington site if not). - The host composes
RunOrBuildAsyncdirectly or viaRunDocSiteAsync/RunBlogSiteAsync(most apps do — confirmProgram.csends with one of those calls). - A writable local directory — the build deletes and re-creates
output/by default.
Steps
Invoke the build verb
Pass build as the first argument to dotnet run. The argument is parsed into OutputOptions via FromArgs; without it, the app starts as a dev server instead. Three argument shapes are supported:
# defaults: BaseUrl = "/", OutputDirectory = "output"
dotnet run -- build
# positional: base URL, then output dir
dotnet run -- build /my-site dist
# named flags (order-independent, preferred for scripts)
dotnet run -- build --base-url=/my-site --output=dist
See CLI and build arguments for the full grammar.
Read the BuildReport printed to stdout
When the crawl finishes, RunOrBuildAsync writes a human-readable report and exits with a non-zero code when the build failed; see Pennington.Generation.BuildReport for the fields and the exact failure conditions. Fix the routes it lists before deploying.
For custom CI presentation (a GitHub Actions summary, a Slack message), use BuildHost.PrintBuildReport in examples/SubPathDeployableExample/BuildHost.cs as a starting point.
Verify
dotnet run -- buildexits0and the stdout report opens withBuild Complete — N pages in Xsfollowed byN pages generated, with noERRORSorWARNINGSsection. A broken internal link is reported as a warning, so an emptyWARNINGSsection means every internal link resolved.output/index.htmlandoutput/404.htmlboth exist — openindex.htmlin a browser to spot-check the rendered output.
Related
- Reference: CLI and build arguments
- Reference: Build report fields
- Background: Dev mode and build mode share one code path