sphinx-llms-txt-link
  • Security Policy
  • Contributor guidelines
  • Contributor Covenant Code of Conduct
  • Release history and notes
  • Package
  • Indices and tables
sphinx-llms-txt-link
  • sphinx-llms-txt-link
  • View page source

sphinx-llms-txt-link

Automatically add a static link to the raw rendered text version (reStructuredText or Markdown format) of every HTML documentation page.

Optimize for LLM Consumption:

  • Provides a direct link to the raw, rendered text markup for the current page.

  • Enables developers to quickly copy clean, structured context for feeding into an LLM prompt.

PyPI Version Supported Python versions Build Status Documentation Status llms.txt - documentation for LLMs MIT Coverage

TL;DR

sphinx-llms-txt-link is a Sphinx extension that injects a server-side rendered link to the .txt version of each HTML page, specifically optimized for LLMOps and training consumption.

Features

  • Server-Side Injection: Uses the doctree-resolved hook to insert a docutils.nodes.raw element, ensuring the link is in the static HTML source.

  • 100% Indexable: Guarantees visibility for all crawlers (Google, specialized LLM scrapers, RAG indexers).

  • Theme Agnostic: Works reliably across themes (Read the Docs, Alabaster, Furo, etc.) without requiring template overrides.

  • Auto-Calculated Relative Path: Correctly calculates the relative path to the sibling .txt file, avoiding common issues with Sphinx’s internal link resolution.

  • Simple Styling Integration: Injects a standard CSS class (sphinx-llms-txt-link) for easy styling and theme-specific overrides.

Prerequisites

  • Python 3.9+

  • Sphinx 6.0+

Your Sphinx documentation must be configured to output .txt files (e.g., using sphinx_markdown_builder or ensuring the text builder runs).

Installation

pip install sphinx-llms-txt-link

Documentation

  • Documentation is available on the Read the Docs project.

  • For guidelines on contributing check the Contributor guidelines.

Usage example

Sphinx configuration

Essential configuration

Add the extension to your conf.py. No other configuration is required.

Filename: docs/conf.py

extensions = [
    # ... other extensions
    "sphinx_llms_txt_link",
    # ... other extensions
]

Custom styling (optional)

The extension injects the following minimal HTML structure at the end of the document body:

<div class="llm-link-container">
    <a href="current_page_name.txt" class="llm-link">
        View llms.txt version
    </a>
</div>

If you wish to style the link to match your theme (e.g., Alabaster or Read the Docs), you can create a CSS file (e.g., _static/custom_sphinx_llms_txt_link.css) and include it in your conf.py settings:

Filename: docs/conf.py

html_css_files = [
    "custom_sphinx_llms_txt_link.css",
]

Build process

Ensure you run the standard HTML build command. If you use a tool like sphinx-markdown-builder or a custom extension to generate the .txt artifacts, ensure those artifacts exist in the build directory.

# Build the .txt files
sphinx-build -n -b text docs builddocs

# Build the HTML output and inject the link
sphinx-build -n -a -b html docs builddocs

The link will now appear at the bottom of every generated HTML page, pointing correctly to its .txt counterpart.

Tests

Run the tests with pytest:

pytest

License

MIT

Support

For security issues contact me at the e-mail given in the Author section.

For overall issues, go to GitHub.

Author

Artur Barseghyan <artur.barseghyan@gmail.com>

Project documentation

Contents:

Table of Contents

  • sphinx-llms-txt-link

    • Features

    • Prerequisites

    • Installation

    • Documentation

    • Usage example

      • Sphinx configuration

        • Essential configuration

        • Custom styling (optional)

        • Build process

    • Tests

    • License

    • Support

    • Author

    • Project documentation

  • Security Policy
    • Reporting a Vulnerability
    • Supported Versions
  • Contributor guidelines
    • Developer prerequisites
    • Code standards
    • Requirements
    • Virtual environment
    • Documentation
    • Testing
    • Pull requests
    • Questions
    • Issues
  • Contributor Covenant Code of Conduct
    • Our Pledge
    • Our Standards
    • Enforcement Responsibilities
    • Scope
    • Enforcement
    • Enforcement Guidelines
    • Attribution
  • Release history and notes
    • 0.1.2
    • 0.1.1
    • 0.1
  • Package
    • sphinx_no_pragma module
  • Indices and tables
View llms.txt version
Next

© Copyright 2025 Artur Barseghyan.

Built with Sphinx using a theme provided by Read the Docs.