
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
docusaurus-plugin-llms
Advanced tools
Docusaurus plugin for generating LLM-friendly documentation following the llmstxt.org standard
A Docusaurus plugin for generating LLM-friendly documentation following the llmstxt standard.
llms.txt with section linksllms-full.txt with all content in one filenpm install docusaurus-plugin-llms --save-dev
Then add to your Docusaurus configuration:
module.exports = {
// ... your existing Docusaurus config
plugins: [
'docusaurus-plugin-llms',
// ... your other plugins
],
};
You can configure the plugin by passing options:
module.exports = {
// ... your existing Docusaurus config
plugins: [
[
'docusaurus-plugin-llms',
{
// Options here
generateLLMsTxt: true,
generateLLMsFullTxt: true,
docsDir: 'docs',
ignoreFiles: ['advanced/*', 'private/*'],
title: 'My Project Documentation',
description: 'Complete reference documentation for My Project',
includeBlog: true,
// Content cleaning options
excludeImports: true,
removeDuplicateHeadings: true,
// Generate individual markdown files following llmstxt.org specification
generateMarkdownFiles: true,
// Control documentation order
includeOrder: [
'getting-started/*',
'guides/*',
'api/*',
],
includeUnmatchedLast: true,
// Path transformation options
pathTransformation: {
// Paths to ignore when constructing URLs (will be removed if found)
ignorePaths: ['docs'],
// Paths to add when constructing URLs (will be prepended if not already present)
addPaths: ['api'],
},
// Custom LLM files for specific documentation sections
customLLMFiles: [
{
filename: 'llms-python.txt',
includePatterns: ['api/python/**/*.md', 'guides/python/*.md'],
fullContent: true,
title: 'Python API Documentation',
description: 'Complete reference for Python API'
},
{
filename: 'llms-tutorials.txt',
includePatterns: ['tutorials/**/*.md'],
fullContent: false,
title: 'Tutorial Documentation',
description: 'All tutorials in a single file'
}
],
},
],
// ... your other plugins
],
};
| Option | Type | Default | Description |
|---|---|---|---|
description | string | Site tagline | Custom description to use in generated files |
docsDir | string | 'docs' | Base directory for documentation files |
excludeImports | boolean | false | Remove import statements from generated content |
generateLLMsFullTxt | boolean | true | Whether to generate the full content file |
generateLLMsTxt | boolean | true | Whether to generate the links file |
ignoreFiles | string[] | [] | Array of glob patterns for files to ignore |
includeBlog | boolean | false | Whether to include blog content |
includeOrder | string[] | [] | Array of glob patterns for files to process in specific order |
includeUnmatchedLast | boolean | true | Whether to include unmatched files at the end |
llmsFullTxtFilename | string | 'llms-full.txt' | Custom filename for the full content file |
llmsTxtFilename | string | 'llms.txt' | Custom filename for the links file |
pathTransformation.addPaths | string[] | [] | Path segments to add when constructing URLs |
pathTransformation.ignorePaths | string[] | [] | Path segments to ignore when constructing URLs |
pathTransformation | object | undefined | Path transformation options for URL construction |
removeDuplicateHeadings | boolean | false | Remove redundant content that duplicates heading text |
title | string | Site title | Custom title to use in generated files |
version | string | undefined | Global version to include in all generated files |
customLLMFiles | array | [] | Array of custom LLM file configurations |
generateMarkdownFiles | boolean | false | Generate individual markdown files and link to them from llms.txt |
rootContent | string | (see below) | Custom content to include at the root level of llms.txt |
fullRootContent | string | (see below) | Custom content to include at the root level of llms-full.txt |
The rootContent and fullRootContent options allow you to customize the introductory content that appears in your generated files, following the llmstxt.org standard which allows "zero or more markdown sections (e.g. paragraphs, lists, etc) of any type except headings" after the title and description.
If not specified, the plugin uses these defaults:
Example 1: Add project-specific context
rootContent: `Welcome to the MyProject documentation.
This documentation covers:
- Installation and setup
- API reference
- Advanced usage guides
- Troubleshooting
For the latest updates, visit https://myproject.dev/changelog`
Example 2: Add technical specifications
fullRootContent: `Complete offline documentation bundle for MyProject v2.0.
**Format**: Markdown with code examples
**Languages**: JavaScript, TypeScript, Python
**Last Generated**: ${new Date().toISOString()}
> Note: Some features require authentication tokens.
> See the Authentication section for details.`
Example 3: Add navigation hints for AI assistants
rootContent: `This documentation is optimized for AI assistants and LLMs.
Quick navigation:
- For API endpoints, search for "API:"
- For code examples, search for "Example:"
- For configuration, search for "Config:"
All code examples are MIT licensed unless otherwise noted.`
You can also specify root content for each custom LLM file:
customLLMFiles: [
{
filename: 'llms-api.txt',
includePatterns: ['api/**/*.md'],
fullContent: true,
title: 'API Documentation',
rootContent: `Complete API reference for all REST endpoints.
Authentication required for all endpoints except /health.
Base URL: https://api.example.com/v2`
}
]
The path transformation feature allows you to manipulate how URLs are constructed from file paths:
Example 1: Remove 'docs' from the URL path
pathTransformation: {
ignorePaths: ['docs'],
}
File path: /content/docs/manual/decorators.md → URL: https://example.com/manual/decorators
Example 2: Add 'api' to the URL path
pathTransformation: {
addPaths: ['api'],
}
File path: /content/manual/decorators.md → URL: https://example.com/api/manual/decorators
Example 3: Combine both transformations
pathTransformation: {
ignorePaths: ['docs'],
addPaths: ['api'],
}
File path: /content/docs/manual/decorators.md → URL: https://example.com/api/manual/decorators
The configuration supports multiple path segments in both arrays.
The document ordering feature allows you to control the sequence in which files appear in the generated output:
Example 1: Basic Section Ordering
includeOrder: [
'getting-started/*',
'guides/*',
'api/*',
'advanced/*'
]
Result: Files will appear in the generated output following this section order.
Example 2: Strict Inclusion List
includeOrder: [
'public-docs/**/*.md'
],
includeUnmatchedLast: false
Result: Only files matching 'public-docs/**/*.md' are included, all others are excluded.
Example 3: Detailed Ordering with Specific Files First
includeOrder: [
'getting-started/installation.md',
'getting-started/quick-start.md',
'getting-started/*.md',
'api/core/*.md',
'api/plugins/*.md',
'api/**/*.md'
]
Result: Installation and quick-start guides appear first, followed by other getting-started files, then API documentation in a specific order.
The plugin fully supports Docusaurus partials - reusable MDX content files that can be imported into other documents.
_shared-config.mdx) are automatically excluded from the generated llms*.txt filesGiven a partial file _api-config.mdx:
## API Configuration
Set your API endpoint:
```javascript
const API_URL = 'https://api.example.com';
And a document that imports it:
```mdx
---
title: Getting Started
---
# Getting Started Guide
import ApiConfig from './_api-config.mdx';
<ApiConfig />
Now you can make API calls...
The plugin will:
_api-config.mdx from llms.txt<ApiConfig /> with the actual content in the processed documentIn addition to the standard llms.txt and llms-full.txt files, you can generate custom LLM-friendly files for different sections of your documentation with the customLLMFiles option:
customLLMFiles: [
{
filename: 'llms-python.txt',
includePatterns: ['api/python/**/*.md', 'guides/python/*.md'],
fullContent: true,
title: 'Python API Documentation',
description: 'Complete reference for Python API'
},
{
filename: 'llms-tutorials.txt',
includePatterns: ['tutorials/**/*.md'],
fullContent: false,
title: 'Tutorial Documentation',
description: 'All tutorials in a single file'
}
]
Each custom LLM file is defined by an object with the following properties:
| Option | Type | Required | Description |
|---|---|---|---|
filename | string | Yes | Name of the output file (e.g., 'llms-python.txt') |
includePatterns | string[] | Yes | Glob patterns for files to include |
fullContent | boolean | Yes | true for full content like llms-full.txt, false for links only like llms.txt |
title | string | No | Custom title for this file (defaults to site title) |
description | string | No | Custom description for this file (defaults to site description) |
ignorePatterns | string[] | No | Additional patterns to exclude (combined with global ignoreFiles) |
orderPatterns | string[] | No | Order patterns for controlling file ordering (similar to includeOrder) |
includeUnmatchedLast | boolean | No | Whether to include unmatched files last (default: false) |
version | string | No | Version information for this LLM file (overrides global version) |
Create separate files for different programming languages:
customLLMFiles: [
{
filename: 'llms-python.txt',
includePatterns: ['api/python/**/*.md', 'guides/python/*.md'],
fullContent: true,
title: 'Python API Documentation'
},
{
filename: 'llms-javascript.txt',
includePatterns: ['api/javascript/**/*.md', 'guides/javascript/*.md'],
fullContent: true,
title: 'JavaScript API Documentation'
}
]
Separate tutorials from API reference:
customLLMFiles: [
{
filename: 'llms-tutorials.txt',
includePatterns: ['tutorials/**/*.md', 'guides/**/*.md'],
fullContent: true,
title: 'Tutorials and Guides'
},
{
filename: 'llms-api.txt',
includePatterns: ['api/**/*.md', 'reference/**/*.md'],
fullContent: true,
title: 'API Reference'
}
]
Create a beginner-focused file with carefully ordered content:
customLLMFiles: [
{
filename: 'llms-getting-started.txt',
includePatterns: ['**/*.md'],
ignorePatterns: ['advanced/**/*.md', 'internal/**/*.md'],
orderPatterns: [
'introduction.md',
'getting-started/*.md',
'tutorials/basic/*.md',
'examples/simple/*.md'
],
fullContent: true,
title: 'Getting Started Guide',
description: 'Beginner-friendly documentation with essential concepts'
}
]
Include version information in your documentation files:
plugins: [
[
'docusaurus-plugin-llms',
{
// Global version applies to all files
version: '2.0.0',
// Custom LLM files with specific versions
customLLMFiles: [
{
filename: 'api-reference.txt',
title: 'API Reference Documentation',
description: 'Complete API reference for developers',
includePatterns: ['**/api/**/*.md', '**/reference/**/*.md'],
fullContent: true,
version: '1.0.0' // Overrides global version
},
{
filename: 'tutorials.txt',
title: 'Tutorials and Guides',
description: 'Step-by-step tutorials and guides',
includePatterns: ['**/tutorials/**/*.md', '**/guides/**/*.md'],
fullContent: true,
version: '0.9.5-beta' // Overrides global version
}
]
}
],
]
The generated files will include the version information under the description:
# API Reference Documentation
> Complete API reference for developers
Version: 1.0.0
This file contains all documentation content in a single document following the llmstxt.org standard.
The plugin provides advanced content cleaning options to optimize your documentation for LLM consumption by removing unnecessary elements that can clutter the output.
excludeImports)The excludeImports option removes JavaScript/TypeScript import statements from your MDX files, which are typically not useful for LLMs and can create noise in the generated documentation.
Before (with excludeImports: false):
import ApiTabs from "@theme/ApiTabs";
import DiscriminatorTabs from "@theme/DiscriminatorTabs";
import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";
import MimeTabs from "@theme/MimeTabs";
import ParamsItem from "@theme/ParamsItem";
# Create User Account
This endpoint creates a new user account...
After (with excludeImports: true):
# Create User Account
This endpoint creates a new user account...
{
excludeImports: true, // Remove all import statements
}
removeDuplicateHeadings)The removeDuplicateHeadings option removes redundant content that simply repeats the heading text immediately after the heading, which is common in auto-generated API documentation.
Before (with removeDuplicateHeadings: false):
# Create Deliverable
Create Deliverable
---
# Update User Profile
Update User Profile
---
After (with removeDuplicateHeadings: true):
# Create Deliverable
---
# Update User Profile
---
{
removeDuplicateHeadings: true, // Remove redundant heading text
}
For optimal LLM-friendly output, you can combine both options:
module.exports = {
plugins: [
[
'docusaurus-plugin-llms',
{
// Enable both content cleaning options for optimal LLM output
excludeImports: true,
removeDuplicateHeadings: true,
// Other configuration options...
generateLLMsTxt: true,
generateLLMsFullTxt: true,
docsDir: 'docs',
},
],
],
};
{
excludeImports: false,
removeDuplicateHeadings: false
}
{
excludeImports: true,
removeDuplicateHeadings: false
}
{
excludeImports: true,
removeDuplicateHeadings: true
}
If you have auto-generated API documentation (like OpenAPI docs), enable both cleaning options:
{
excludeImports: true, // Remove React component imports
removeDuplicateHeadings: true, // Remove redundant API endpoint descriptions
generateLLMsFullTxt: true, // Create comprehensive single file
}
For hand-written tutorials and guides, you might want selective cleaning:
{
excludeImports: true, // Remove any MDX imports
removeDuplicateHeadings: false, // Keep all content as written
includeOrder: [ // Organize content logically
'getting-started/*',
'tutorials/*',
'advanced/*'
]
}
Create separate clean files for different programming languages:
{
excludeImports: true,
removeDuplicateHeadings: true,
customLLMFiles: [
{
filename: 'llms-python.txt',
includePatterns: ['**/python/**/*.md'],
fullContent: true,
title: 'Python Documentation'
},
{
filename: 'llms-javascript.txt',
includePatterns: ['**/javascript/**/*.md'],
fullContent: true,
title: 'JavaScript Documentation'
}
]
}
Both options default to false, ensuring existing configurations continue to work without changes. Only users who explicitly enable these features will see the cleaned output.
generateMarkdownFiles)The generateMarkdownFiles option enables the plugin to generate individual markdown files for each documentation page, following the llmstxt.org specification more closely. When enabled, this creates separate .md files for LLM consumption instead of linking to your original documentation pages.
Default Behavior (generateMarkdownFiles: false):
llms.txt with links to your original documentation pages[Getting Started](https://yoursite.com/docs/getting-started)With generateMarkdownFiles: true:
getting-started.md, api-reference.md)llms.txt with links to these generated markdown files[Getting Started](https://yoursite.com/getting-started.md)module.exports = {
plugins: [
[
'docusaurus-plugin-llms',
{
generateMarkdownFiles: true, // Enable individual markdown file generation
generateLLMsTxt: true, // Generate index file linking to markdown files
excludeImports: true, // Clean up import statements
removeDuplicateHeadings: true, // Remove redundant content
// Other options work normally
includeOrder: ['getting-started/*', 'guides/*', 'api/*'],
pathTransformation: {
ignorePaths: ['docs']
}
}
]
]
}
With generateMarkdownFiles: true, your output directory will contain:
build/
├── llms.txt # Index file with links to generated markdown files
├── llms-full.txt # Full content file (if enabled)
├── getting-started.md # Generated from your getting started docs
├── api-reference.md # Generated from your API documentation
├── user-guide.md # Generated from your user guides
└── ... # Other generated markdown files
The plugin generates readable filenames using this priority:
getting-started.md)getting-started-1.md)Generated markdown files include:
Input documentation about "API Authentication" would generate api-authentication.md:
# API Authentication
> Learn how to authenticate with our API using various methods
## Overview
This guide covers all authentication methods supported by our API...
## API Key Authentication
Use your API key to authenticate requests:
```javascript
const client = new Client({ apiKey: 'your-key' });
### Use Cases
#### Standards-Compliant Documentation
Perfect for projects that want to follow the llmstxt.org specification exactly:
```js
{
generateMarkdownFiles: true,
generateLLMsTxt: true,
generateLLMsFullTxt: false // Optional: disable if only individual files are needed
}
Generate clean markdown files for LLM training or fine-tuning:
{
generateMarkdownFiles: true,
excludeImports: true,
removeDuplicateHeadings: true,
customLLMFiles: [
{
filename: 'training-data.txt',
includePatterns: ['**/*.md'],
fullContent: true
}
]
}
Generate both original links and markdown files for different use cases:
{
generateLLMsTxt: true, // Links to original pages
generateMarkdownFiles: true, // Also generate individual markdown files
llmsTxtFilename: 'llms-original.txt', // Original links file
// The markdown-linked version will be in llms.txt
}
false, existing configurations unchangedincludeOrderThis plugin automatically generates the following files during the build process:
These files follow the llmstxt standard, making your documentation optimized for use with Large Language Models (LLMs).
The plugin:
docs directory recursively for all Markdown filesllms.txtllms-full.txtThe plugin includes comprehensive tests in the tests directory:
To run the tests:
# Run all tests
npm test
# Run just the unit tests
npm run test:unit
# Run just the integration tests
npm run test:integration
For more detailed testing instructions, see tests/TESTING.md.
Planned features for future versions:
This project is licensed under the MIT License.
FAQs
Docusaurus plugin for generating LLM-friendly documentation following the llmstxt.org standard
We found that docusaurus-plugin-llms demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.