shelldocs preview

shelldocs preview serves the static site that shelldocs build wrote, the way GitHub Pages, Netlify and Cloudflare Pages serve it. Use it to check an export before you deploy: links, the not-found page, search, a site built for a subpath.

Synopsis

bash
shelldocs preview [--dir <dir>] [--output <path>] [--port <n>] [--base-href <path>]

Default use

Build, then preview, from the docs project folder:

bash
shelldocs build
shelldocs preview

The export in ./publish is served at http://localhost:5050. Press Ctrl+C to stop.

How it serves

Prop Type Default Description
A file 200 — Served as it is, with a content type from its extension.
A folder 200 — Its index.html. Every page of an export is a folder with an index.html.
{path}.html 200 — Used when there is no file or folder of that name.
Anything else 404 — The export's 404.html, with a 404 status, as most static hosts do.

Nothing is cached, so after a rebuild a reload shows the new output. Requests can't reach files outside the export.

Sites built for a subpath

An export built with --base-href /my-repo/ is served under that path. shelldocs preview reads the base from the export's index.html, so it needs no flag:

bash
shelldocs build --base-href /my-repo/
shelldocs preview

The site is at http://localhost:5050/my-repo/, and / redirects there. Pass --base-href to serve under another path than the one the build wrote.

Options

Prop Type Default Description
--dir string current folder Project folder. --output is relative to it.
--output string publish The static site to serve, as passed to shelldocs build.
--port int 5050 Port to listen on.
--base-href string? the export's base href Path to serve the site under.

Exit codes

Prop Type Default Description
0 ok — Stopped with Ctrl+C.
1 error — No index.html in the output folder. Run shelldocs build first, or point --output at its folder.

The command needs the ASP.NET Core runtime, which any machine that builds a Blazor site already has. It was added in 0.1.18-alpha, replacing an unfinished preview <name> placeholder.

See also