Generating an llms.txt takes seconds. Here are 4 ways it comes out wrong

2026-12-03来源 dev.toEnglish

When we crawled HTTPX's docs to test llms.txt generation, the QuickStart page and the Timeouts page both described themselves the same way: "A next-generation HTTP client for Python." So did every other page: the site uses one meta description for all of them. Feed that into a generator and every link in your llms.txt gets the same line under it, which tells an agent nothing about any of them.

Making an llms.txt is quick. Checking it is where the work is. Below are the two ways I'd generate one, what each produces, and a small script that catches the problems you can catch automatically.

The 30-second version of the format

From the proposal at llmstxt.org: a Markdown file at your site's root with an H1 (the only required part), an optional blockquote summary, then H2 sections of links, each [name](url) with an optional : note. llms-full.txt isn't in the proposal. It's a convention docs platforms publish beside it: every page's content in one file.

Route 1: from the sitemap (free, seconds)

We built a free llms.txt generator into MeshArc. Paste a domain and it reads robots.txt, follows the sitemaps it names and groups the URLs into sections by the first part of each path.

What you get, and what you don't:

  • The H1 is the site's host.
  • Each link shows the URL's path. It doesn't read the pages, so there are no titles and no descriptions.
  • It needs a sitemap, and returns at most 400 lines and 60 URLs per section.
  • No account. It allows 10 requests an hour and 40 a day per IP.

Treat it as a first draft: the structure is there, the notes under each link are yours to write.

Route 2: from a crawl (with the page descriptions)

A crawl reads every page, so the export can write each link from the page's own title and description. With the Python SDK:

pip install mesharc export MESHARC_API_KEY=mesharc_... 
from mesharc import MeshArc arc = MeshArc() # reads MESHARC_API_KEY project = arc.projects.create( "https://www.python-httpx.org/", name="HTTPX", # this becomes the file's H1 schedule="weekly", # re-crawled every week config={"max_pages": 100}, ) arc.runs.start(project["id"], wait=True) arc.export(project["id"], "llms.txt", dataset="llms", fmt="txt") arc.export(project["id"], "llms-full.txt", dataset="llms-full", fmt="txt") 

The H1 is the project's name, not the host, so name the project after the site. The file comes out in this shape:

# <project name>  > <the home page's meta description>  <host>: N pages read by MeshArc on <date>; the pages a model can use are listed below. ## Pages  - [title](url): description ## /advanced  - [title](url): description 

Every top-level page goes together under ## Pages, which comes first. Pages in a sub-folder go under a section named after the folder. llms-full.txt lands beside it with every usable page's Markdown, each under its title and a Source: line.

Without the SDK it's a GET to https://api.mesharc.dev/api/v1/projects/{id}/export?dataset=llms&format=txt with your key as a Bearer token. Exports are free (you pay 1 credit for each plain page the crawl reads), and we ran both on a small project on 27 November 2026. With a weekly schedule, your deploy job can pull the two exports after each run and publish them.

4 ways a generated llms.txt goes wrong

1. The same description under every link. The HTTPX problem from the top. It's common in docs themes. The real fix is in your pages: give each one its own meta description, and every other tool that reads them gets better too. Otherwise, edit the lines by hand after generating.

2. Sections that aren't sections. HTTPX's sitemap has one folder with depth, /advanced/ (10 pages). The other 13 URLs each sit in a top-level segment of their own. The free generator makes one section per first path segment, so you get a pile of one-link sections and one real one. The crawl export goes the other way and puts all 13 under a single catch-all ## Pages, which isn't much more useful to a reader. Neither has a setting for this, so merge them by hand into what a reader would expect, such as Guides, API and Advanced.

3. Pages blocked on that run, missing from the file. The crawl export lists the run's usable pages only. A page the site refused that day is reported as blocked, not as removed, but it won't be in that run's file. Before you publish a rebuilt llms.txt, look at the run's counts. If pages were refused, keep last week's file.

4. An llms-full.txt too big to use. Mintlify notes that its file may be truncated once it passes 100 KB. On a big site, one file per section works better.

A quick checker

Problems 1, 4 and the one-link kind of 2 are visible in the files themselves, so I'd run something like this before publishing. Problem 3 isn't: a missing page leaves no trace in the file, so that one needs the run's counts.

import re, sys from collections import Counter from pathlib import Path def check(path, full_path=None): text = Path(path).read_text(encoding="utf-8") sections, current, descs = {}, None, [] for line in text.splitlines(): if line.startswith("## "): current = line[3:].strip() sections[current] = 0 m = re.match(r"\s*-\s*\[([^\]]*)\]\(([^)]+)\)(?::\s*(.+))?", line) if m and current is not None: sections[current] += 1 if m.group(3): descs.append(m.group(3).strip()) # 1. the same description under many links for desc, n in Counter(descs).most_common(3): if n > 1: print(f"same description under {n} links: {desc[:60]!r}") # 2. sections with a single link lonely = [s for s, n in sections.items() if n == 1] if lonely: print(f"{len(lonely)} one-link sections: {', '.join(lonely[:5])}") # 4. llms-full.txt size if full_path: kb = Path(full_path).stat().st_size / 1024 if kb > 100: print(f"llms-full.txt is {kb:.0f} KB; consider one file per section") if __name__ == "__main__": check(*sys.argv[1:3]) 
python check_llms.py llms.txt llms-full.txt 

On a test file with three identical descriptions, two one-link sections and a 198 KB llms-full.txt, it prints:

same description under 3 links: 'A next-generation HTTP client.' 2 one-link sections: /changelog, /api llms-full.txt is 198 KB; consider one file per section 

When not to generate it at all

If fewer than about 30 pages matter, write it by hand. You'll write better notes than any generator, ours included. And if your docs already live on a platform that publishes one for you, use that.

Have you shipped an llms.txt yet, and has anything you know of actually read it?

Originally published on mesharc.dev.

原文:https://www.a8q9.cn/en/article/generating-an-llms-txt-takes-seconds-here-are-4-ways-it-comes-out-wrong-dc4547.html

相关文章