How to add llms.txt to VitePress
VitePress powers a lot of dev-tool documentation — and docs are the most natural home for llms.txt, since your sidebar is already a hand-picked index of the pages that matter. As a static-site generator, VitePress gives you full control of the output root.
Generate the file first — paste your docs URL and get a spec-compliant llms.txt from your real pages, then drop it in with the method below.
Generate my llms.txt →Method A — Public directory (simplest)
Drop the file at .vitepress/public/llms.txt (or the public/ folder if you set srcDir). VitePress copies it to the build root, so after vitepress build it's live at /llms.txt with the right text/plain type. Add llms-full.txt the same way.
Method B — Generate from your sidebar (buildEnd hook)
Keep the file in sync with your docs by writing it in the buildEnd hook of your config, straight into the output directory:
// .vitepress/config.ts
import { defineConfig } from "vitepress";
import { writeFileSync } from "node:fs";
import { resolve } from "node:path";
export default defineConfig({
title: "My Docs",
description: "Docs for My Tool",
buildEnd(siteConfig) {
const base = "https://yoursite.com";
const body = `# ${siteConfig.site.title}
> ${siteConfig.site.description}
## Docs
- [Getting started](${base}/guide/): install and first run
- [Configuration](${base}/config/): every option
- [API](${base}/api/): reference
`;
writeFileSync(resolve(siteConfig.outDir, "llms.txt"), body);
},
});Build the link list from your themeConfig.sidebar so the index always reflects your real navigation.
What to watch for
- base path — a non-root
basepushes public files under it. Serve at the root or redirect/llms.txtat your host. - Curate, don't dump — link your top sections, not every markdown file. llms.txt is an index, not a sitemap.
- Don't block AI bots — check that your host (GitHub Pages, Netlify, Cloudflare Pages) and robots.txt let GPTBot / ClaudeBot through.
Generate llms.txt and llms-full.txt from your docs URL, then ship it with Method A or B.
Try the free llms.txt generator →Related: llms.txt for Docusaurus · llms.txt for Next.js · How to create llms.txt · vs sitemap.xml