Skip to main content

Generate llms.txt from built HTML documentation

Project description

llmstxt-standalone

CI PyPI Python License codecov prek

Generate /llms.txt, /llms-full.txt, and per-page markdown files from built HTML documentation, following the llms.txt spec.

This tool works on pre-built HTML, making it useful for environments that cannot run MkDocs plugins (e.g., Zensical) or when you want llms.txt generation as a separate build step. For standard MkDocs workflows, see mkdocs-llmstxt.

Installation

Requires Python 3.10+.

# Run without installing
uvx llmstxt-standalone

# Install as a CLI tool
uv tool install llmstxt-standalone  # or: pipx install

# Add to a project
uv add llmstxt-standalone  # or: pip install

Usage

# Run from project root (expects mkdocs.yml and site/)
llmstxt-standalone

# Explicit paths
llmstxt-standalone --config mkdocs.yml --site-dir ./build --output-dir ./dist

# Preview without writing files
llmstxt-standalone --dry-run

# Suppress output
llmstxt-standalone --quiet

# Show detailed progress
llmstxt-standalone --verbose
Option Short Default Description
--config -c mkdocs.yml Path to MkDocs config file
--site-dir -s site Path to built HTML directory
--output-dir -o same as site-dir Where to write output files
--dry-run -n Preview without writing
--quiet -q Suppress output
--verbose -v Show detailed progress
--version -V Show version

Output

The tool generates three outputs:

  1. llms.txt — an index file with markdown links to all pages
  2. llms-full.txt — concatenated content of all pages
  3. Per-page .md files alongside the HTML

The per-page markdown files make the URLs in llms.txt resolve to actual content. If your site is at https://docs.example.com/, the URL https://docs.example.com/install/index.md returns markdown instead of HTML.

Configuration

The tool reads your mkdocs.yml for site metadata. You can configure llmstxt output explicitly or let it derive structure from your nav.

Explicit configuration

plugins:
  - llmstxt:
      markdown_description: |
        Extra context for LLMs about your project.
      full_output: llms-full.txt
      content_selector: article.md-content__inner
      sections:
        Getting Started:
          - index.md
          - install.md
        Usage:
          - guide/basics.md
          - guide/advanced.md
Option Default Description
markdown_description "" Additional context for LLMs, appears after site description
full_output llms-full.txt Filename for concatenated content
content_selector auto-detect CSS selector for main content
sections derived from nav Section names mapped to page lists

Automatic fallback

Without an explicit llmstxt plugin config, sections derive from your nav structure. Top-level pages go into a "Pages" section; nested nav items become sections named by their keys.

MkDocs settings

The tool respects use_directory_urls from your mkdocs.yml. When enabled (the default), install.md maps to install/index.md; when disabled, it maps to install.md.

Content extraction

If content_selector is not set, the tool tries these selectors in order:

  1. .md-content__inner (Material for MkDocs)
  2. [role="main"] (default MkDocs theme)
  3. article
  4. main
  5. The entire document

Title resolution

Page titles resolve in this order:

  1. The title from your nav structure
  2. The HTML <title> tag (with site name suffix stripped)
  3. The first <h1> tag
  4. A title derived from the filename

Programmatic use

from pathlib import Path
from llmstxt_standalone.config import load_config
from llmstxt_standalone.generate import generate_llms_txt

config = load_config(Path("mkdocs.yml"))
result = generate_llms_txt(config, site_dir=Path("site"))

print(result.llms_txt)       # Index content
print(result.llms_full_txt)  # Full content
print(result.markdown_files) # List of written .md paths

Compatibility

  • Produces output identical to mkdocs-llmstxt when configured the same way
  • Handles Unicode, international characters, and special characters
  • Works with Material for MkDocs, ReadTheDocs, and the default MkDocs theme
  • Parses configs containing Python YAML tags like !python/object/apply

License

MIT

Project details


Download files

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

Source Distribution

llmstxt_standalone-0.1.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

llmstxt_standalone-0.1.1-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file llmstxt_standalone-0.1.1.tar.gz.

File metadata

  • Download URL: llmstxt_standalone-0.1.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llmstxt_standalone-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4e601968c98cef4f4fd61a09afd5a406a4b5f3038794c0b145f26a2c050a6853
MD5 2280331c7cf1e11e6c5838bad13eda20
BLAKE2b-256 97df59471a4560b8788196d88e6e183ca6e970011ef6d198f70ed283900aaff4

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmstxt_standalone-0.1.1.tar.gz:

Publisher: release.yml on shaanmajid/llmstxt-standalone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmstxt_standalone-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: llmstxt_standalone-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llmstxt_standalone-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93de4d83172d1315d41ef70b86a546b718df9186f6b2ad3378f1d094db5382f4
MD5 973c5d0940f427f72fd74738fef48cee
BLAKE2b-256 bc2ef08acc8791432c6e1a52aeaa28788492dc6c1d4f03c985bd03ec4ad5bbf8

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmstxt_standalone-0.1.1-py3-none-any.whl:

Publisher: release.yml on shaanmajid/llmstxt-standalone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page