Skip to main content

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

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>

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_llms_txt_link-0.1.2.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_llms_txt_link-0.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page