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.
description field to your frontmatter. It improves search relevance and appears in the llms.txt output for AI agents.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:
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 |
Alternate languages
Sites with i18n add hreflang tags to pages that have translations. See Internationalization.
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:
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:
Every robots.txt group then gets this line:
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 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 has the details, and MCP server covers connecting a client.
llms.txt, search index, Markdown URLs, and content negotiation support. Agents can fetch this single file to learn how to interact with your docs.list_pages, get_page, and search_docs tools with no additional dependencies.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.
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:
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:
For versioned sites, pass the version-specific index if needed:
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
npxcommand 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 against the published URL.
Add it to your project's .claude/settings.json:
Then ask Claude Code to search or read your docs directly from the conversation.
Add it to your Claude Desktop configuration:
Restart Claude Desktop to pick up the new server.
Add it to your project's .cursor/mcp.json:
Any MCP client that supports stdio transport can use the server. Point it at node dist/mcp-server.js as the command.
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).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.
For static builds, DocsLit generates platform-specific files to handle this negotiation automatically.
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.
Run docslit deploy --vercel once in your project root and commit the two files it writes:
middleware.jsreturns a page's Markdown when theAcceptheader preferstext/markdown. Vercel runs it before serving static files.vercel.jsonsets the build command, the output directory, clean URLs and the.mdcontent type. If you already have avercel.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.
Move _middleware.js into your netlify/edge-functions/ directory, or reference it in your netlify.toml:
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.
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
Write a one-sentence description for every page. This improves search results, llms.txt quality, and helps readers decide if a page is relevant.
Add "url" to your docslit.json to enable sitemap.xml generation with absolute URLs.
Write headings that describe what the section covers. Headings are indexed for search and appear in the table of contents.
Next steps
- Start adding rich content with callouts and alerts
- Deploy your site with static hosting or DocsLit Cloud