---
title: Static hosting
description: Deploy your DocsLit site as static files to Netlify, Vercel, Cloudflare Pages, GitHub Pages, or any CDN.
tag: Deployment
readtime: 4 min read
---
> For AI agents: the complete documentation index is at [llms.txt](https://docs.docslit.com/0.3/llms.txt). This page as Markdown: [deployment/static-hosting.md](https://docs.docslit.com/0.3/deployment/static-hosting.md).


# Static hosting

DocsLit builds a standard static site that you can deploy to any hosting provider. Run `docslit build` and upload the `dist/` directory.

## Build your site

```bash
docslit build
```

This generates a `dist/` directory with HTML pages, a search index, sitemap, and AI discovery files.

<wc-callout type="tip" title="Set the url field">
Add `"url": "https://docs.example.com"` to your `docslit.json` before building. This enables absolute URLs in your sitemap and `llms.txt`.
</wc-callout>

## Deploy recipes

Generate host-specific config files from the CLI:

```bash
docslit deploy --github-pages
docslit deploy --netlify
docslit deploy --cloudflare
docslit deploy --vercel
```

For GitHub project sites (`https://user.github.io/repo/`), set `"basePath": "/repo"` in `docslit.json` so asset and navigation URLs stay correct.

## Deploy to a hosting provider

<wc-tabs>
<wc-tab label="Vercel">

<wc-steps>
<wc-step title="Install the Vercel CLI">

```bash
npm install -g vercel
```

</wc-step>
<wc-step title="Write the Vercel files">

```bash
docslit deploy --vercel
```

This writes `vercel.json`, which sets the build command, the `dist` output directory and clean URLs, and `middleware.js`, which serves Markdown to AI agents that send `Accept: text/markdown`. Commit both files.

</wc-step>
<wc-step title="Deploy">

Run this from your project root, not from `dist/`:

```bash
vercel --prod
```

</wc-step>
</wc-steps>

Alternatively, connect your git repository to Vercel. It picks up the build command and output directory from `vercel.json`. If you deploy only the `dist/` folder, the site works but Markdown negotiation does not, because Vercel reads `middleware.js` from the project root.

</wc-tab>
<wc-tab label="Netlify">

<wc-steps>
<wc-step title="Install the Netlify CLI">

```bash
npm install -g netlify-cli
```

</wc-step>
<wc-step title="Deploy">

```bash
docslit build
netlify deploy --prod --dir=dist
```

</wc-step>
</wc-steps>

For continuous deployment, connect your repository and set the build command to `docslit build` with the publish directory set to `dist`.

</wc-tab>
<wc-tab label="GitHub Pages">

<wc-steps>
<wc-step title="Add a GitHub Actions workflow">

Create `.github/workflows/deploy.yml`:

```yaml filename=".github/workflows/deploy.yml"
name: Deploy docs
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      pages: write
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm install -g docslit
      - run: docslit build
      - uses: actions/upload-pages-artifact@v3
        with:
          path: dist
      - uses: actions/deploy-pages@v4
```

</wc-step>
<wc-step title="Enable GitHub Pages">

Go to your repository **Settings** > **Pages** and set the source to **GitHub Actions**.

</wc-step>
</wc-steps>

</wc-tab>
<wc-tab label="AWS S3">

<wc-steps>
<wc-step title="Build and sync">

```bash
docslit build
aws s3 sync dist/ s3://your-bucket-name --delete
```

</wc-step>
<wc-step title="Configure static hosting">

Enable static website hosting on your S3 bucket and set `index.html` as the index document. Optionally, put CloudFront in front for HTTPS and caching.

</wc-step>
</wc-steps>

</wc-tab>
</wc-tabs>

## Redirects and headers by host

Pattern redirects and the agent headers depend on files that only some hosts read.

| Host | Pattern redirects | Headers |
|---|---|---|
| Netlify | Yes, from `_redirects` | Yes, from `_headers` |
| Cloudflare Pages | Yes, from `_redirects` | Yes, from `_headers` |
| Vercel | Yes, from `vercel.json` | Yes, from `vercel.json` |
| GitHub Pages | No. Exact redirects still work through HTML redirect pages | No |

Headers include `noindex` on `.md` files, the `Link` discovery header and `Content-Signal`. See [How agents read your site](../ai-and-agents/reading-agents#http-headers-and-discovery) and [Redirects](../customization/site-chrome#redirects).

GitHub Pages runs Jekyll by default, which hides folders that start with a dot. The build writes an empty `.nojekyll` file so `.well-known/`, including `agent.json` and published skills, is served.

If you set `basePath`, `.well-known/` sits under that subpath, where discovery tools that only check the domain root won't find it. See [the limitation on the skills page](../ai-and-agents/agent-skills#limitation-with-basepath).

## What gets deployed

Every build produces these files:

| File | Purpose |
|---|---|
| `index.html` | Redirect to the first page, with a canonical link to it |
| `{slug}.html` | Pre-rendered pages for SEO |
| `{slug}.md` | Raw Markdown for programmatic access |
| `search-index.json` | Client-side full-text search |
| `sitemap.xml` | Search engine sitemap |
| `robots.txt` | Crawler directives |
| `llms.txt` | AI agent discovery index |
| `llms-full.txt` | Complete docs as plain text |
| `_middleware.js` | Content negotiation for AI agents (Cloudflare/Netlify) |
| `vercel.json` | Clean URLs, redirects, and headers for `.md` files and agent discovery (Vercel) |
| `_headers`, `_redirects` | Response headers and redirects (Netlify and Cloudflare Pages) |
| `.nojekyll` | Makes GitHub Pages serve the `.well-known/` folder |
| `.well-known/agent.json` | Machine-readable agent discovery |
| `mcp-server.js` | MCP server for AI tool integration |
| `pdf/` | Chapter, page, and full documentation PDFs (when built with `--pdf`) |

<wc-callout type="tip" title="Chapter PDFs">
Run `docslit build --pdf` to generate downloadable PDF manuals alongside your HTML site. See [Chapter PDF export](chapter-pdf-export).
</wc-callout>

## Custom output directory

Use the `--out` flag to change the output directory:

```bash
docslit build --out public
```
