Sub topic 7
llms-full.txt and Markdown versions of pages
This chapter assumes you have read the earlier chapters on the llms.txt file format and on what llms.txt does not do. You should also be comfortable with HTTP response headers and basic Markdown. Here you will learn what llms-full.txt is, how Markdown copies of pages fit the llms.txt proposal, how to generate both, and which failure modes to expect.
Where these files come from
The llms.txt proposal describes an index file. It lists links and short descriptions, and a reader (a person or an AI tool) decides which links to follow. That design depends on the linked pages being easy to read. HTML pages carry navigation, scripts, cookie banners and layout markup. These add tokens without adding meaning when the page is pasted into a model's context window.
The proposal therefore suggests that a site also publish clean Markdown versions of its pages. The usual convention is to take the page URL and append .md, so https://example.com/docs/quickstart is also served as https://example.com/docs/quickstart.md. The llms.txt example in this tutorial links to .md pages for that reason.
llms-full.txt is a related convention. It is one file containing the full text of the documentation, with no links to follow. Documentation platforms popularised it, so you will find it on many developer documentation sites. The original proposal does not define it as strictly as it defines llms.txt. Treat its layout as a common practice, not a standard.
| File | Contents | Reader's job |
|---|---|---|
| `llms.txt` | Titles, links and one-line descriptions | Choose which links to fetch |
| `page.md` | One page as plain Markdown | Read one page |
| `llms-full.txt` | All chosen pages concatenated | Load everything in one request |
How the pieces relate
All three outputs should come from one source. If you write each by hand, they drift apart. The diagram shows a single build step that produces every variant.
What llms-full.txt looks like
The file is plain Markdown. A common layout has one H1 for the whole site, then one section per page. Each section records the page title and its canonical URL, so a reader can tell where a passage came from.
# Example Docs
> Documentation for the Example library, a Python client for the Example API.
## Quickstart
Source: https://example.com/docs/quickstart
Install the library with pip, then create a client with your API key.
## API reference
Source: https://example.com/docs/api
Each endpoint accepts JSON and returns JSON. Errors use standard HTTP status codes.Notice the heading levels. Inside each page, headings should sit below the section heading. If a page's own H1 is kept at level 1, the file has many H1s and the structure becomes ambiguous. A generator should demote headings or drop the page's own H1 and use it as the section title.
Generating the files
The script below builds llms-full.txt from a folder of Markdown pages. It strips YAML front matter, uses each file's first line as the section title, and records the source URL. It creates two sample pages first so you can run it as shown.
from pathlib import Path
BASE_URL = "https://example.com/docs"
def strip_front_matter(text: str) -> str:
"""Remove a leading YAML block delimited by '---' lines."""
if text.startswith("---\n"):
end = text.find("\n---\n", 4)
if end != -1:
return text[end + 5:]
return text
def build_full(src: Path, out: Path, site_title: str, summary: str) -> int:
parts = [f"# {site_title}\n\n> {summary}\n"]
count = 0
for page in sorted(src.glob("*.md")):
body = strip_front_matter(page.read_text(encoding="utf-8")).strip()
lines = body.splitlines()
if not lines:
continue
title = lines[0].lstrip("# ").strip()
rest = "\n".join(lines[1:]).strip()
url = f"{BASE_URL}/{page.stem}"
parts.append(f"## {title}\n\nSource: {url}\n\n{rest}\n")
count += 1
out.write_text("\n".join(parts), encoding="utf-8")
return count
if __name__ == "__main__":
docs = Path("docs")
docs.mkdir(exist_ok=True)
(docs / "quickstart.md").write_text(
"---\ntitle: Quickstart\n---\n# Quickstart\n\nInstall the library with pip.\n",
encoding="utf-8",
)
(docs / "api.md").write_text(
"# API reference\n\nEach endpoint returns JSON.\n", encoding="utf-8"
)
n = build_full(
docs,
Path("llms-full.txt"),
"Example Docs",
"Documentation for the Example library.",
)
print(f"Wrote llms-full.txt with {n} pages")Running it prints Wrote llms-full.txt with 2 pages. In a real build you would run the same step in your CI pipeline, so the file is regenerated on every publish.
Serving Markdown correctly
Serving the files is mostly a matter of headers. A .md URL should return the Markdown as text, with a charset, so that browsers and tools do not guess.
HTTP/1.1 200 OK
Content-Type: text/markdown; charset=utf-8
Cache-Control: public, max-age=3600
Link: <https://example.com/docs/quickstart>; rel="canonical"Several details matter here:
text/markdownis the registered media type. Some servers sendapplication/octet-streamfor unknown extensions, and a browser then downloads the file instead of showing it. Some tools also treat that type as binary.llms.txtandllms-full.txtend in.txt, so servers usually sendtext/plain. That is fine. Add; charset=utf-8if your server does not.- A
Linkheader withrel="canonical"points back to the HTML page. Without it, a search engine that crawls both versions may treat the Markdown copy as a duplicate. You can also keep the.mdfiles out of search indexes with anX-Robots-Tag: noindexheader, covered in a later chapter. Decide whether you want them indexed. The point of the files is to serve AI tools, not to compete with your pages in search results.
Some sites also use content negotiation. The same URL returns Markdown when the request carries Accept: text/markdown, and HTML otherwise. If you do this, send Vary: Accept so caches do not hand the wrong version to the next visitor. Content negotiation is less visible than a .md URL and harder to debug, so many sites use the explicit suffix.
You can check what your server returns with a request that prints only the headers.
curl -sI https://example.com/docs/quickstart.md | grep -i -E "^(HTTP|content-type|link)"
curl -sI -H "Accept: text/markdown" https://example.com/docs/quickstart | grep -i -E "^(HTTP|content-type|vary)"Size, scope and staleness
The central design decision for llms-full.txt is size. A model's context window is finite. A file with 400 pages of documentation can exceed it, and then the file helps nobody. A tool that fetches it may truncate it or reject it. Consider these options:
- Include only the pages that answer common questions, such as quickstart, concepts and reference.
- Split by product or version, for example
/docs/v2/llms-full.txt, and link each from llms.txt. - Leave out changelogs, marketing pages and legal text. The Optional section of llms.txt is the right place to point at those.
Staleness is the second problem. A generated file is correct on the day it is built. If your build step does not run on every content change, the file will describe an old version of the product. A model that reads an outdated llms-full.txt can then give a user wrong instructions with confidence. Generate the files in the same pipeline that publishes the HTML, and fail the build if generation fails.
A third issue is fidelity. Converting HTML to Markdown loses tables, tabbed code examples and content rendered by JavaScript. If you convert from rendered HTML instead of from your Markdown source, check the output by reading it. Compare the Markdown version with the page for a sample of URLs.
What to expect from these files
The earlier chapter on limits applies in full here. Publishing llms-full.txt does not grant ranking, does not force citation, and does not control access. The file is public. Anyone, including crawlers you have blocked in robots.txt, can request it. Do not put anything in it that you would not publish openly.
Whether a given AI tool fetches these files is an empirical question. Some developer tools and documentation assistants do read them, often because a user points the tool at the URL. Large search engines have not committed to using them. The access-log technique shown later in this tutorial lets you test this on your own site.
The honest case for these files is cost and benefit. They are cheap to generate once you have a build step. They help people who paste documentation into a coding assistant, and they make your content easier to read for any tool that chooses to use them. They are not a substitute for clear HTML, a good sitemap and accurate content.
Exercise
Your documentation has 600 pages and a changelog with thousands of entries. A teammate proposes concatenating everything into one llms-full.txt. Give two problems with this plan and one alternative.
Show answer
First, the file will likely exceed the context window of the tools that read it, so it may be truncated or ignored, and the changelog adds many tokens with little value for answering questions. Second, a hand-built or rarely rebuilt file goes stale and can mislead readers about the current product. An alternative is to generate a smaller llms-full.txt per product or version from only the core pages, rebuild it in the publishing pipeline, and list the changelog under the Optional section of llms.txt as a link.
Exercise
A browser downloads https://example.com/docs/api.md as a file instead of displaying it. Which header is the likely cause, and what value should the server send?
Show answer
The Content-Type header is probably application/octet-stream or another binary type, because the server does not know the .md extension. It should send Content-Type: text/markdown; charset=utf-8.