See More

# `shelldocs preview` > Serve the output of shelldocs build locally, the way a static host would, to check an export before deploying it. Source: https://shelldocs.shellui.dev/docs/cli/preview `shelldocs preview` serves the static site that [`shelldocs build`](https://shelldocs.shellui.dev/docs/cli/build.md) 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

] [--output ] [--port ] [--base-href ] ``` ## 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 | Name | 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 | Name | 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 | Name | 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 ` placeholder. ## See also - [shelldocs build](https://shelldocs.shellui.dev/docs/cli/build.md): Write the static site this command serves. - [Deployment](https://shelldocs.shellui.dev/docs/guides/deployment.md): What works on a static host, and how to publish.