MkDocs LLMstxt Plugin
MkDocs plugin to generate an `/llms.txt` file, a standard for providing LLM-friendly content summaries and links from websites. It automatically processes your MkDocs documentation during the build process, creating a concise index of content accessible to AI language models. The plugin can also generate a `/llms-full.txt` file with concatenated content and per-page Markdown files. The project is currently in maintenance mode.
Common errors
-
Plugin 'llmstxt' not found.
cause The `mkdocs-llmstxt` package is not installed in your environment, or it's not correctly listed under the `plugins` section in `mkdocs.yml`.fixEnsure `pip install mkdocs-llmstxt` has been run and your `mkdocs.yml` includes: ```yaml plugins: - llmstxt: # ... your configuration ... ``` -
The `llms.txt` file is not generated, or the URLs within it are relative/incorrect.
cause The `site_url` configuration option is missing or incorrectly set in your `mkdocs.yml`, which is required for the plugin to generate absolute URLs.fixAdd or correct the `site_url` in your `mkdocs.yml`: ```yaml site_url: https://your-domain.com/ # Must be an absolute URL ``` Also ensure the `sections` configuration is present and correctly defined for the plugin. -
Files listed in `llms.txt` are not found (e.g., 404 errors when an LLM tries to access them).
cause This could happen if the paths specified in the `sections` configuration of `mkdocs.yml` do not correctly map to your actual Markdown files, or if the `base_url` option is needed for specific hosting environments (e.g., Read the Docs).fixVerify that file paths in the `sections` configuration match your `docs` directory structure. If hosting on a subdirectory or specific version, consider using the `base_url` option in your `llmstxt` plugin configuration: `plugins: - llmstxt: base_url: https://productname.hostname.io/en/0.1.34`.
Warnings
- breaking The configuration options of the `llmstxt` plugin changed significantly in version 0.2.0. If upgrading from 0.1.0, review your `mkdocs.yml` plugin configuration.
- gotcha The `site_url` option in `mkdocs.yml` is mandatory for `mkdocs-llmstxt` to function correctly and generate absolute URLs in the `/llms.txt` file. Without it, links may be relative or incorrect.
- gotcha The `mkdocs-llmstxt` project is currently in maintenance mode. While it continues to function, active development and new features are limited. Consider this when planning long-term usage.
- gotcha Prior to version 0.5.0, relative links within your documentation might not have been correctly resolved to absolute URLs in the generated `/llms.txt` or associated Markdown files.
Install
-
pip install mkdocs-llmstxt
Quickstart
mkdir my-llm-docs
cd my-llm-docs
# Create a minimal MkDocs config
cat <<EOF > mkdocs.yml
site_name: My LLM Project
site_url: https://example.com/ # REQUIRED for llmstxt plugin
site_description: A concise description of my project for LLMs.
plugins:
- llmstxt:
markdown_description: >
This is a longer, more detailed description of the project.
It provides additional context for AI models.
sections:
Introduction:
- index.md: Key concepts and overview
Guides:
- guides/*.md # Glob patterns are supported
API Reference:
- api/reference.md
EOF
# Create some example documentation files
mkdir docs docs/guides docs/api
cat <<EOF > docs/index.md
# Welcome to My LLM Project
This is the main introduction to our project.
EOF
cat <<EOF > docs/guides/setup.md
# Setup Guide
Follow these steps to set up the project.
EOF
cat <<EOF > docs/api/reference.md
# API Reference
Details about the API endpoints.
EOF
# Build the documentation, which generates llms.txt
mkdocs build
echo "\nCheck the 'site' directory for llms.txt and the generated Markdown files."
# To serve locally:
# mkdocs serve