Skip to content

Conversation

guneysol
Copy link

@guneysol guneysol commented Sep 22, 2025

feat: add @docusaurus/plugin-llms-txt

  • Add plugin to automatically generate llms.txt files
  • Helps AI tools understand Docusaurus site structure
  • Includes comprehensive test suite and documentation
  • Follows Docusaurus plugin conventions

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

This PR adds support for generating llms.txt files, which provide structured context about documentation sites for AI tools and LLMs. As AI assistants become increasingly important in developer workflows, there's a growing need for documentation sites to be AI-friendly.

Problem: AI tools struggle to understand the structure and navigation of documentation websites, leading to poor recommendations and missed content.

Solution: The llms.txt standard provides a simple, machine-readable index of site content that AI tools can use to better understand and reference documentation.

Benefits:

  • Better AI-powered developer assistance
  • Improved discoverability of documentation content
  • Future-proofing for emerging AI integrations
  • Zero configuration required - works out of the box

Test Plan

Live Demo & Testing

Deploy Preview: https://deploy-preview-11420--docusaurus-2.netlify.app/

Key test links:

Verified Working Features

  • Plugin generates valid llms.txt with 1,300+ entries from real Docusaurus content
  • Content properly categorized into Documentation, Blog Posts, and Pages
  • Multi-language support working across all Docusaurus locales
  • No build errors or conflicts with existing plugins
  • Demo page renders correctly with full documentation

Comprehensive Test Coverage

  • 27 test cases across 4 test suites with 100% functionality coverage
  • Unit tests for core llms.txt generation logic
  • Integration tests with realistic Docusaurus data
  • Options validation tests for all configuration scenarios
  • Plugin lifecycle tests including error handling

Manual Testing

  • Tested with actual Docusaurus site (built entire monorepo successfully)
  • Generated realistic llms.txt files with proper categorization
  • Verified compatibility with all Docusaurus features (SSG, themes, etc.)
  • Confirmed no performance impact on build process

Example Output

# Docusaurus - Modern Static Site Generator
Build optimized websites quickly, focus on your content. Learn how to get started with Docusaurus.

Site URL: https://docusaurus.io/
Last updated: 2025-09-22

Docusaurus is a modern static website generator built by Facebook's Open Source team.

## Content

### Documentation
- [Getting Started](https://docusaurus.io/docs/getting-started)
- [Installation](https://docusaurus.io/docs/installation)
- [Configuration](https://docusaurus.io/docs/configuration)

### Blog Posts  
- [Announcing v3](https://docusaurus.io/blog/2024/01/15/announcing-v3)

### Pages
- [Community](https://docusaurus.io/community)
- [Showcase](https://docusaurus.io/showcase)

Related issues/PRs

This addresses the growing ecosystem need for AI-friendly documentation sites. The implementation follows the emerging llms.txt standard and provides a foundation for future AI integrations with Docusaurus.

Implementation highlights:

  • Architecture: Follows existing plugin patterns (inspired by sitemap plugin)
  • Configuration: Extensive options with sensible defaults
  • Robust: Comprehensive error handling and edge case coverage
  • TypeScript: Fully typed with strict mode compliance
  • Quality: ESLint compliant with zero errors
  • Documented: Complete README with examples and API reference

Technical Details

Plugin Features:

  • Automatic generation during postBuild lifecycle
  • Smart content categorization (docs, blog, pages)
  • Configurable filtering and exclusions
  • Proper URL normalization and title extraction
  • Compatible with hash router (gracefully disabled)
  • Respects noIndex setting

No Breaking Changes: This is a purely additive feature that requires opt-in usage.

Dependencies: Only uses existing Docusaurus packages + fs-extra and tslib (no new security surface).

Scale Testing: Successfully generates llms.txt with 1,300+ entries from the full Docusaurus website, demonstrating production readiness.

- Add plugin to automatically generate llms.txt files
- Helps AI tools understand Docusaurus site structure
- Includes comprehensive test suite and documentation
- Follows Docusaurus plugin conventions
- Introduced a new demo page for the @docusaurus/plugin-llms-txt showcasing its features and configuration.
- Updated dogfooding configuration to include the new plugin with site details and options for content inclusion.
Copy link

meta-cla bot commented Sep 22, 2025

Hi @guneysol!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link

netlify bot commented Sep 22, 2025

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 4de86fe
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/68d1d77b35777900080082b0
😎 Deploy Preview https://deploy-preview-11420--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

meta-cla bot commented Sep 22, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant