---
title: Publish the site
description: Publish your documentation on Turn Zero Cloud, the recommended host, or use GitHub Pages, Netlify or Cloudflare Pages as alternatives.
slug: /guides/publish-the-site
order: 7
visibility: public
redirects_from: []
---

# Publish the site

Prompt:

> Publish our documentation site on Turn Zero Cloud.

Also works:

- "Publish our docs on GitHub Pages under the repository's name."
- "Deploy the docs to Netlify."
- "Search engines can't find our docs pages."
- "Make a missing address on our docs site show its own styled 404 page."

Turn Zero Cloud is the recommended host for a tzDocs site. GitHub Pages, Netlify and Cloudflare Pages are alternatives.

The examples on this page build one corpus. For several products in one build, see [Build one site for several products](/tzdocs/guides/several-products/).

Decide whether the site needs a base path and an origin ([step 1](#1-choose-the-base-path-and-the-origin)). Build for Turn Zero Cloud as [step 2](#2-build-for-turn-zero-cloud) describes. For another host, follow [step 3](#3-build-for-github-pages) or [step 4](#4-or-build-for-netlify-or-cloudflare-pages). Check the result as [step 7](#7-look-at-the-result) describes.

## What your AI tool does

- Finds the site's address, leaves out `--base` for the host's root, and uses its scheme and host as `--origin`.
- Builds and deploys the output folder, or configures the chosen host to build it and serve that folder.
- Builds, serves the output folder locally, and opens a page, a missing address, and `sitemap.xml`.
- Asks for the site's address if the project does not state it.

## What you need

- The host, and the address the site will be served at.

## Before your AI starts

Your AI coding agent checks these things before publishing.

- A corpus that passes the check and builds ([Getting started](/tzdocs/getting-started/)).

## Steps

### 1. Choose the base path and the origin

Two flags describe where the site lives:

- `--base` is the path the site is served under, such as `/docs`. Leave it out when the site has the whole host to itself.
- `--origin` is `http://` or `https://` followed by a hostname or IPv4 address and an optional port, such as `https://example.com`. Leave out the path. With it, each page gives its canonical address, and the build writes `sitemap.xml`.

The pages link each other relatively, so they work under any base path. The base path goes into the machine files and into the 404 page, whose links are absolute paths.

### 2. Build for Turn Zero Cloud

Publish the built site as a public static application. [Publish a static site](https://turnzero.ai/cloud/guides/publish-a-static-site/) gives the connection, manifest and deploy steps.

1. Connect your signed-in AI assistant to tzCloud. Have it create an application with `kind: "serverless"` and no `size`, following that guide.
2. Read the application's hostname with `read_status` before you build; it is available before the first deploy. Build the documentation for that host's root: leave out `--base` and set `--origin` to `https://` followed by the hostname.
3. Copy the contents of the built `site` folder into `client/` in the deploy folder, beside `manifest.json`. Keep the names and folder layout; do not put a containing `site/` folder inside `client/`.
4. Use [the static-site manifest](https://turnzero.ai/cloud/guides/publish-a-static-site/#2-submit-the-manifest): empty `services`, `egress` and `packages`, `region` set to `usa`, a public `audience`, and no `health`.
5. Check the output against [the static file-count and size bounds](https://turnzero.ai/cloud/guides/publish-a-static-site/#keep-the-files-within-the-bounds). A large documentation corpus can exceed them. Keep private files out of the source folder. The build can copy files that no page links to. For a public site, leave `--include-hidden` off and check the generated files before copying them to `client/`.
6. Follow [Ways to deploy](https://turnzero.ai/cloud/getting-started/ways-to-deploy/) to submit the manifest, check the deploy and send the folder. Use the `turnzero` command, the file-list route or the ZIP upload route as that page directs, within the chosen route's bounds. The ZIP upload route needs a shell.
7. Wait for the deploy to complete. Open a page, `docs.json` and `sitemap.xml` at the returned hostname. Read a page's Markdown copy; a new deploy serves it as `text/markdown; charset=utf-8`. A site deployed earlier keeps its Markdown copies' recorded content type until its next deploy. Then check a missing page address.

On Turn Zero Cloud, keep `404.html` at the root of `client/`. If you built several products, supply a root 404 page for the host because the build puts each product's 404 under its base. A missing page or file then shows that page with HTTP 404. [Step 6](#6-check-missing-page-responses) explains what to check.

<div id="2-build-for-github-pages"></div>

### 3. Build for GitHub Pages

GitHub Pages serves a project site at `https://<user>.github.io/<repository>/`. Build it with the repository's name as the base path.

```text
tzdocs build --source docs --out site --base /<repository> --origin https://<user>.github.io
```

Publish the `site` folder, for example from a workflow that uploads it as the Pages artifact. A user or organization site, or a site on a custom domain, is served at the root of its host. Leave out `--base` for it, and give its address as the origin.

<div id="3-or-build-for-netlify-or-cloudflare-pages"></div>

### 4. Or build for Netlify or Cloudflare Pages

Netlify and Cloudflare Pages build the site from your repository and serve it at the root of its host.

```text
tzdocs build --source docs --out site --origin https://docs.example.com
```

Set `site` as the output or publish folder. For a project installation, add tzdocs to the development dependencies and put the command in an npm script, where the local `tzdocs` command is available:

```json
{
  "scripts": {
    "docs:build": "tzdocs build --source docs --out site --origin https://docs.example.com"
  }
}
```

Merge this script into the existing `package.json`, keeping its other entries. Commit the package lockfile and configure the host to install development dependencies with `npm ci`, then run `npm run docs:build`. For drawn diagrams, install `mermaid` in the project too ([Add callouts and diagrams](/tzdocs/guides/callouts-and-diagrams/)).

<div id="4-offer-the-sitemap"></div>

### 5. Offer the sitemap

With `--origin`, a one-corpus build writes `sitemap.xml` at the root of its output, one address per page in navigation order. A build of several products writes a separate sitemap under each product's base. It lists no redirect stub, and it carries no dates, so two builds of one source stay identical. Without `--origin` the build writes no sitemap, because a sitemap must give absolute addresses.

Give the sitemap's address, such as `https://example.com/docs/sitemap.xml`, to a search engine's site tools. Or name it in the `robots.txt` at the root of the host, a file the tool does not write.

```text
Sitemap: https://example.com/docs/sitemap.xml
```

<div id="5-rely-on-the-404-page"></div>

### 6. Check missing-page responses

A one-corpus build writes `404.html` at the root of its output. A build of several products writes one under each product's base. Supply a site-wide 404 page separately if your host expects one. GitHub Pages, Netlify, and Cloudflare Pages each show a site's root `404.html` for an address that matches no file. On Cloudflare Pages it also keeps a missing address from showing the home page instead.

On Turn Zero Cloud, a `GET` or `HEAD` that no file answers uses the deployed root `404.html` with HTTP 404. A `HEAD` has no response body. This covers missing page paths and paths with a dot. Keep `404.html` at the root when copying the build to `client/`.

Without a root `404.html`, a missing page path shows the root `index.html` with HTTP 200, where that file exists. A missing path whose last segment contains a dot gets the platform's not-found answer.

On these hosts, the generated page says that no page lives at the address and links to the home page. Its stylesheet and home links begin with the base path, so it displays correctly at any depth. It carries no navigation, and it tells search engines not to list it. Under `--shell` it renders into the shell, so it keeps the site's header and footer.

<div id="6-look-at-the-result"></div>

### 7. Look at the result

Match the preview's path to the build's base. For a site with no base path, `npx serve site` serves the output at the local server's root. For a site under `/docs`, build into a `docs` folder inside a dedicated preview folder, then serve its parent:

```text
tzdocs build --source docs --out preview/docs --base /docs --origin https://example.com
npx serve preview
```

Open `/docs/` on the local address the server prints. Check a page, its Markdown link, `/docs/docs.json`, and `/docs/sitemap.xml`. Open `/docs/404.html` directly to check its styling; the preview server may show its own error page for a missing address. On the deployed host, also open a missing address to verify its 404 handling. A browser that opens the files from disk does not resolve the folder links between pages ([Output](/tzdocs/reference/output/#the-tree)).

## Expected result

The host serves the home page at the site's address, and each page's links and stylesheet resolve. On GitHub Pages, Netlify and Cloudflare Pages, a missing address shows the styled 404 page. On Turn Zero Cloud, a missing address shows the deployed root `404.html` with HTTP 404 when that file is present. With `--origin`, each sitemap lists the absolute addresses of the pages it covers.

## Refusals

[Refusals and findings](/tzdocs/reference/refusals/) gives the exact text.

| Message | Exit code | Cause | Remedy |
| --- | --- | --- | --- |
| `--base needs a path that starts with / and does not end with one, such as /docs, not "<value>"` | 2 | The base path does not start with `/`, still ends with `/` after one trailing slash is removed, or has an unsafe segment. | Write the path the site is served under, such as `/docs`. |
| `--origin needs an http or https origin with no path, such as https://example.com, not "<value>"` | 2 | The origin has an unsupported scheme or host form, or includes a path. | Give `http://` or `https://` with a hostname or IPv4 address and optional port. Put the site's path in `--base`. |

## Related

- [Publish a static site on Turn Zero Cloud](https://turnzero.ai/cloud/guides/publish-a-static-site/) gives its manifest, deploy routes and file bounds.
- [Getting started](/tzdocs/getting-started/) lists every flag of the build.
- [Output](/tzdocs/reference/output/#machine-files) describes the sitemap beside the other machine files.
- [Build documentation for AI assistants](/tzdocs/guides/build-for-ai-tools/) covers the files an AI assistant reads.
