---
title: Search and SEO
description: Built-in full-text search, sitemap generation, meta tags, and AI agent discovery with llms.txt for every DocsLit site.
tag: Writing
readtime: 3 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: [writing-content/search-and-seo.md](https://docs.docslit.com/0.3/writing-content/search-and-seo.md).


# Search and SEO

DocsLit generates search indexes, sitemaps, and AI-readable files automatically. You do not need to configure anything — these features work out of the box when you run `docslit build`.

## Built-in search

Every static build generates a `search-index.json` file that powers the client-side search bar. The index includes page titles, descriptions, group names, and full body text.

Readers press `/` or click the search icon to open the search dialog. Results update as they type, with matches ranked by relevance.

<wc-callout type="tip" title="Write good descriptions">
Add a `description` field to your frontmatter. It improves search relevance and appears in the `llms.txt` output for AI agents.
</wc-callout>

## Search engine optimization

### HTML pages

Static builds generate an HTML page at `{slug}.html` for every page in your sidebar. These pages contain the fully rendered content, making them crawlable by search engines.

Every link the build generates resolves from any page depth. Sidebar items, previous and next buttons, tab links, OpenAPI sidebar items and the Docs and API Reference mode links use absolute paths that include `basePath`, the locale and the version, such as `/docs/fr/1.0/get-started/sign-in`.

### Page titles

By default the `<title>` of a page is the page title, a dash and the site name. Set `seo.titleTemplate` to change it. `%s` is the page title and `%site%` is the site name:

```json filename="docslit.json"
{
  "seo": {
    "titleTemplate": "%s | Acme Docs"
  }
}
```

The template applies to the `<title>` of static pages and to the title while readers navigate inside the site. The `og:title` and `twitter:title` tags keep the plain page title.

### Structured data

Each page includes `TechArticle` JSON-LD with a `publisher` Organization:

| Field | Value |
|---|---|
| `name` | `seo.organization.name`, or the site name |
| `url` | `seo.organization.url`, or `url` |
| `logo` | The absolute URL of your logo or favicon. Only when `url` is set and the logo isn't an external URL |
| `sameAs` | The URLs in `footer.socials` |

```json filename="docslit.json"
{
  "seo": {
    "organization": {
      "name": "Acme, Inc.",
      "url": "https://acme.com"
    }
  }
}
```

### Alternate languages

Sites with `i18n` add `hreflang` tags to pages that have translations. See [Internationalization](../customization/i18n#hreflang-tags).

### Site root

The site root `index.html` does not copy the first page. It redirects to the first page and carries a canonical link to it, so search engines never see two URLs with the same content. Each version root (`/<version>/`) and locale root (`/<locale>/`) works the same way.

### Sitemap

When you set the `url` field in `docslit.json`, the build generates a `sitemap.xml`:

```json filename="docslit.json"
{
  "name": "My Docs",
  "url": "https://docs.example.com",
  "sidebar": [...]
}
```

Every URL in the sitemap is the canonical URL of a page, including `basePath` and the version. Root URLs such as `/` and `/<version>/` are redirects, so the sitemap leaves them out.

Submit this sitemap to Google Search Console and other search engines to improve indexing.

### Robots.txt

The build writes a `robots.txt` file only when `url` is set in `docslit.json` and the sitemap isn't disabled. It has an `Allow: /` group for each of these user agents: `*`, `GPTBot`, `ChatGPT-User`, `OAI-SearchBot`, `ClaudeBot`, `Claude-User`, `Claude-SearchBot`, `PerplexityBot`, `Google-Extended`, `Applebot-Extended` and `CCBot`. Its `Sitemap:` lines point at `sitemap.xml`, one for each version on a versioned site, with `basePath` applied. `llms.txt` stays at its well-known path and is not listed as a sitemap.

### Content signals

Content signals tell crawlers how they may use your content. Set the ones you want under `agents.contentSignals`:

```json filename="docslit.json"
{
  "agents": {
    "contentSignals": {
      "search": true,
      "aiInput": true,
      "aiTrain": false
    }
  }
}
```

Every `robots.txt` group then gets this line:

```text
Content-Signal: search=yes, ai-input=yes, ai-train=no
```

The build also sends the same value as a `Content-Signal` response header on every path, through `_headers` and `vercel.json`. Only the keys you set to `true` or `false` appear, always in the order `search`, `ai-input`, `ai-train`. Without this config there is no signal, and nothing defaults to yes.

Signals declare your preferences. They don't block crawlers or enforce access.

### Markdown copies

The `.md` copy of each page is served with `X-Robots-Tag: noindex`, so search engines index the HTML page and not the Markdown. See [How agents read your site](../ai-and-agents/reading-agents#http-headers-and-discovery) for the agent headers.

## AI agent discovery

DocsLit generates several files to make your documentation accessible to AI agents. This page is a summary. [How agents read your site](../ai-and-agents/reading-agents) has the details, and [MCP server](../ai-and-agents/mcp-server) covers connecting a client.

<wc-fields header="AI discovery files">
<wc-field name="llms.txt" type="file">
A structured index of all your documentation pages with titles and descriptions. AI agents use this to understand your site structure and decide which pages to read. Follows the [llmstxt.org](https://llmstxt.org) specification.
</wc-field>
<wc-field name="llms-full.txt" type="file">
The complete text content of every page concatenated into a single file. AI agents can consume your entire documentation in one request.
</wc-field>
<wc-field name=".well-known/agent.json" type="file">
A machine-readable discovery file listing all available endpoints — `llms.txt`, search index, Markdown URLs, and content negotiation support. Agents can fetch this single file to learn how to interact with your docs.
</wc-field>
<wc-field name="mcp-server.js" type="file">
A standalone MCP server that agents like Claude Desktop can connect to over stdio. Provides `list_pages`, `get_page`, and `search_docs` tools with no additional dependencies.
</wc-field>
</wc-fields>

These files are generated automatically from your page content and frontmatter descriptions. Every page also includes an agent directive (in HTML and Markdown) pointing to your `llms.txt` index, following the [Agent-Friendly Documentation Spec](https://agentdocsspec.com/spec/).

### Versioned sites

For versioned sites (using the `versions` block in `docslit.json`), the build generates a root `/llms.txt` that acts as a version index:

```markdown
# My Docs
> Version-specific documentation indexes are listed below.

## Versions
- [0.2.0 (default)](https://docs.example.com/0.2.0/llms.txt): Documentation for version 0.2.0
- [0.1.0](https://docs.example.com/0.1.0/llms.txt): Documentation for version 0.1.0
```

Each version's own `llms.txt` then lists the individual pages for that version. AI agents can start at the root index and navigate to the relevant version automatically.

Validate your deployed site with [afdocs](https://github.com/agent-ecosystem/afdocs):

```bash
npx afdocs check https://docs.example.com
```

For versioned sites, pass the version-specific index if needed:

```bash
npx afdocs check https://docs.example.com --llms-txt-url https://docs.example.com/0.1/llms.txt --doc-version 0.1
```

### Copy page dropdown

Every page includes a **Copy page** split button in the page action bar. Readers can use it to:

- **Copy page** — copy the page as Markdown, ready to paste into any LLM chat
- **Open in ChatGPT** — opens ChatGPT pre-seeded with a question about the page URL
- **Open in Claude** — opens Claude pre-seeded with the page URL
- **Copy MCP install command** — copies the `npx` command to install your site's MCP server

No configuration is needed — the button appears automatically on every page.

### MCP server

The generated `mcp-server.js` is a self-contained Node script that implements the Model Context Protocol over stdio. It requires no additional dependencies — just Node.js. It provides three tools:

| Tool | Description |
|---|---|
| `list_pages` | List all pages with titles and descriptions |
| `get_page` | Get the full Markdown content of a page by slug |
| `search_docs` | Search documentation by keyword with excerpts |

After building your site with `docslit build`, the MCP server is ready to use at `dist/mcp-server.js`. For a site with `versions` the tools take an optional `version` argument and default to the default version. You can also use [reader mode](../ai-and-agents/mcp-server#reader-mode) against the published URL.

<wc-tabs sync="mcp-client">
<wc-tab label="Claude Code">

Add it to your project's `.claude/settings.json`:

```json filename=".claude/settings.json"
{
  "mcpServers": {
    "my-docs": {
      "command": "node",
      "args": ["dist/mcp-server.js"]
    }
  }
}
```

Then ask Claude Code to search or read your docs directly from the conversation.

</wc-tab>
<wc-tab label="Claude Desktop">

Add it to your Claude Desktop configuration:

```json filename="claude_desktop_config.json"
{
  "mcpServers": {
    "my-docs": {
      "command": "node",
      "args": ["/absolute/path/to/dist/mcp-server.js"]
    }
  }
}
```

Restart Claude Desktop to pick up the new server.

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

Add it to your project's `.cursor/mcp.json`:

```json filename=".cursor/mcp.json"
{
  "mcpServers": {
    "my-docs": {
      "command": "node",
      "args": ["dist/mcp-server.js"]
    }
  }
}
```

</wc-tab>
<wc-tab label="Other clients">

Any MCP client that supports stdio transport can use the server. Point it at `node dist/mcp-server.js` as the command.

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

<wc-callout type="tip" title="Keep it in your repo">
Commit `dist/mcp-server.js` to your repository so that contributors and AI tools can use it without needing to rebuild. The server reads the `.md` and `search-index.json` files from the same output folder (from the version folders on a versioned site).
</wc-callout>

### Content negotiation

AI agents can request any page URL with an `Accept: text/markdown` header to receive raw Markdown instead of HTML. This works automatically in the dev server and in static builds deployed to platforms that support edge middleware.

The middleware reads quality values in the `Accept` header. A request gets Markdown when it ranks `text/markdown` at least as high as `text/html`, so `text/markdown, text/html;q=0.9` gets Markdown. Browsers never ask for `text/markdown`, so they keep getting HTML.

```bash
# Returns raw Markdown instead of the HTML page
curl -H "Accept: text/markdown" https://docs.example.com/quickstart
```

For static builds, DocsLit generates platform-specific files to handle this negotiation automatically.

<wc-tabs>
<wc-tab label="Cloudflare Pages">

`docslit build` writes the middleware to `dist/functions/_middleware.js` and never touches your source tree. Cloudflare Pages reads Functions from `functions/` at your project root, so run `docslit deploy --cloudflare` once (after a build) to install it there; later builds keep that copy up to date. The build also writes `_headers` into `dist/` so `.md` files are served with `Content-Type: text/markdown`.

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

Run `docslit deploy --vercel` once in your project root and commit the two files it writes:

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

- `middleware.js` returns a page's Markdown when the `Accept` header prefers `text/markdown`. Vercel runs it before serving static files.
- `vercel.json` sets the build command, the output directory, clean URLs and the `.md` content type. If you already have a `vercel.json`, the command keeps it. Make sure yours sets `"cleanUrls": true`.

Vercel reads both files only from the project root, so deploy the project, not the `dist/` folder on its own. A `vercel.json` rewrite cannot do this negotiation, because Vercel applies rewrites only after a static file fails to match.

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

Move `_middleware.js` into your `netlify/edge-functions/` directory, or reference it in your `netlify.toml`:

```toml filename="netlify.toml"
[[edge_functions]]
  path = "/*"
  function = "markdown-negotiation"
```

</wc-tab>
<wc-tab label="Other platforms">

On platforms without middleware support (GitHub Pages, S3), agents can request Markdown directly at `/{slug}.md`. The `llms.txt` file lists these URLs for discovery.

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

## Offline search

The offline build mode (`docslit build --offline`) produces a `search-index.js` file that loads on demand when search is first used. Search works without a server — even when opening the file from your desktop via `file://`.

## Best practices

<wc-steps>
<wc-step title="Add frontmatter descriptions">

Write a one-sentence `description` for every page. This improves search results, `llms.txt` quality, and helps readers decide if a page is relevant.

</wc-step>
<wc-step title="Set the url field">

Add `"url"` to your `docslit.json` to enable `sitemap.xml` generation with absolute URLs.

</wc-step>
<wc-step title="Use descriptive headings">

Write headings that describe what the section covers. Headings are indexed for search and appear in the table of contents.

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

## Next steps

- Start adding rich content with [callouts and alerts](../components/callouts-and-alerts)
- Deploy your site with [static hosting](../deployment/static-hosting) or [DocsLit Cloud](../deployment/docslit-cloud)
