plugin-llms
Add llms.txt to your site to provide LLM-friendly content.
Usage
npm i -D @vuepress/plugin-llms@nextimport { llmsPlugin } from '@vuepress/plugin-llms'
export default {
plugins: [
llmsPlugin({
// options
}),
],
}Why llms.txt?
Large Language Models (LLMs) increasingly rely on web-based documentation to answer user queries and write code. However, standard websites present significant challenges: context windows are limited, and raw HTML—cluttered with navigation, scripts, and styling—is token-expensive and difficult to parse.
llms.txt bridges this gap. It creates a standardized entry point for AI agents, providing a concise summary of your project and direct links to clean, expert-level documentation. This is particularly critical for development tools, ensuring LLMs have accurate, low-noise access to your APIs and guides.
Plugin Overview
This plugin automatically converts your VuePress documentation into a structured dataset optimized for machine reading.
During the build process, it generates the following assets in your output directory:
📂 .vuepress/dist
├── ...
├── llms.txt # The entry point / map of your documentation
├── llms-full.txt # A single file containing your entire documentation
├── markdown-examples.html # Your standard web page
└── markdown-examples.md # The clean Markdown version of that pageTips
These files are generated only during the production build (i.e., when running vuepress build). They will appear in the .vuepress/dist directory alongside your HTML files.
Output Files
1. llms.txt
The llms.txt file acts as the primary index for AI agents. It contains the Title, Description, Details (Optional), and a Table of Contents (TOC) for your site.
You can view the generated file for this documentation site here: llms.txt.
Default Format:
# Title
> Description
Details (Optional)
## Table of Contents
- [Title](url): Description
- [Title](url): Description
- ...Content Resolution Logic:
The plugin determines the content for these fields based on the following priority order (highest priority first):
Site Title:
Site Description:
llmsTxtTemplateGetter.descriptiontaglinein the locale homepage frontmatter- The current locale's description in the VuePress config
- The main description in the VuePress config
frontmatter.descriptionin the locale homepage (README.md)
Site Details (Optional):
llmsTxtTemplateGetter.detailsfrontmatter.detailsin the locale homepage (README.md)
Table of Contents (TOC):
Formatted as- [title](url): description. Thedescriptionis pulled from the page'sfrontmatter.description.By default, a flat, first-level TOC is generated. You can customize this behavior (e.g., to support multi-level nesting) by defining a custom getter in the
llmsTxtTemplateGetteroption.
2. llms-full.txt
The llms-full.txt file is a concatenated version of your documentation. It merges the content of all Markdown files into a single text stream, allowing LLMs to ingest your entire knowledge base in one request.
You can view the full file for this site here: llms-full.txt.
Format:
---
url: /path/to/page
description: A brief summary of the page
---
# Page Title
Full Markdown content of the page...
---
---
url: /path/to/next-page
description: ...
---
...3. Individual Page Content
In addition to the summary files, the plugin generates a clean Markdown file for every HTML page in your site.
For example, if your site has a page at /guide/quick-start.html, the plugin generates a corresponding /guide/quick-start.md file. This allows LLMs to fetch specific pages with zero HTML noise.
Options
llmsTxt
Type:
booleanDefault:
trueDetails: Specifies whether to generate the
llms.txtfile (the index file containing links to section summaries).
llmsFullTxt
Type:
booleanDefault:
trueDetails: Specifies whether to generate the
llms-full.txtfile (a consolidated text file containing the entire documentation).
llmsPageTxt
Type:
booleanDefault:
trueDetails: Specifies whether to generate individual LLM-friendly Markdown files for each page of the website.
stripHTML
Type:
booleanDefault:
trueDetails: Determines whether HTML tags should be stripped from the generated Markdown files to ensure cleaner input for LLMs.
filter
Type:
(page: Page) => booleanDefault:
() => trueDetails:
A function to filter which pages are included. If the function returns
true, the page is included inllms.txt.Note that pages explicitly disabled via
frontmatter.llmstxtor pages not generated from Markdown sources will always be excluded, regardless of this setting.
domain
Type:
stringDefault:
''Details:
An optional domain to prepend to all URLs in
llms.txtand other generated files.While standard relative paths are often sufficient, some AI agents may handle absolute URLs better. Use this option if you need to enforce fully qualified URLs (e.g.,
https://example.com/foo/bar.md).- [title](/foo/bar.md) - [title](https://example.com/foo/bar.md)
locale
Types:
string | 'all'Default:
'/'Details:
Controls which locale to generate content for.
- If unset, it defaults to the site's root locale.
- If set to a specific locale key (e.g.,
'/zh/'), it generates files only for that language. - If set to
'all', the plugin generatesllms.txtresources for every configured locale.
::: tip Why use
'all'?If your documentation contains specialized terminology or concepts that LLMs struggle to translate accurately, generating dedicated
llms.txtfiles for each language ensures that international users (and their AI assistants) receive the most precise information available.:::
llmsTxtTemplate
Types:
stringDefault:
const DEFAULT_LLMSTXT_TEMPLATE = `\ # {title} {description} {details} ## Table of Contents {toc}`Details:
Defines the structure of the
llms.txtfile. You can rearrange the default placeholders—{title},{description},{details}, and{toc}—or introduce new ones usingllmsTxtTemplateGetter.
llmsTxtTemplateGetter
Type:
TemplateGetterOptions/** * Link extension options for generated links */ export type LinkExtension = '.html' | '.md' /** * Page with additional LLM-friendly content */ export interface LLMPage extends Page { /** * The page's Markdown content * * @example '# Guide\n\nA guide' */ markdown: string /** * The page's excerpt * * @example 'Introduction to the guide' */ excerpt: string } /** * State object for LLM text generation */ export interface LLMState { /** * VuePress app instance */ app: App /** * Site base URL */ base: string /** * Optional domain to prepend to URLs */ domain?: string /** * Link extension for generated links */ linkExtension?: LinkExtension /** * The path of the current locale. */ currentLocale: string /** * Current site locale data */ siteLocale: SiteLocaleData /** * Whether to generate llms.txt files for all locales. */ allLocales: boolean } export type TemplateGetter = (pages: LLMPage[], state: LLMState) => string export interface TemplateGetterOptions { /** Any custom variable */ [key: string]: TemplateGetter | string | undefined }Default:
{}Details:
Provides custom variables or getter functions for the
llmsTxtTemplate.You can use this to inject static strings or dynamically generated content.
Example: Overriding the title
llmsPlugin({ llmsTxtTemplateGetter: { title: 'My Custom Docs Title', }, })Example: Adding a custom variable
llmsPlugin({ llmsTxtTemplate: '# {title}\n\n{customNote}', llmsTxtTemplateGetter: { customNote: 'Note: This content is optimized for AI agents.', }, })Example: Generating a custom list of pages
llmsPlugin({ llmsTxtTemplate: '# {title}\n\n## Page List\n\n{pageList}', llmsTxtTemplateGetter: { pageList: (pages, state) => pages.map((page) => `- ${page.title}`).join('\n'), }, })
Frontmatter
The plugin respects the following frontmatter properties in your Markdown files.
title
- Types:
string - Details:
- On the homepage (
README.md), this overrides the site title inllms.txt. - On regular pages, this serves as the page title in the Table of Contents.
- On the homepage (
description
Types:
stringDetails:
- On the homepage (
README.md), this overrides the site description inllms.txt. - On regular pages, this provides the page summary in the Table of Contents.
Recommendation: Write clear, concise descriptions for every page to help LLMs understand the context and relevance of the link.
- On the homepage (
heroText
- Types:
string - Details:
- Used exclusively on the homepage (locale
README.md). It serves as the primary title source forllms.txt.
- Used exclusively on the homepage (locale
tagline
- Types:
string - Details:
- Used exclusively on the homepage (locale
README.md). It serves as the primary description source forllms.txt.
- Used exclusively on the homepage (locale
details
- Types:
string - Details:
- Used exclusively on the homepage (locale
README.md). It provides the content for the{details}section inllms.txt.
- Used exclusively on the homepage (locale
llmstxt
- Types:
boolean - Default:
true - Details:
- Controls whether the current page is included in the generated LLM files. Set to
falseto hide a specific page from AI agents.
- Controls whether the current page is included in the generated LLM files. Set to
Others
It is recommended to configure server redirects so that AI agents can reliably access files via .md or .txt extensions, even if they guess the URL structure.
For example, on Netlify, add the following to public/_redirects:
/llms.md /llms.txt 200!
/llms-full.md /llms-full.txt 200!For more details on redirect syntax, refer to the Netlify documentation.
