Published · 8 min read
How to create an llms.txt file for your docs
Learn how to create llms.txt for your documentation: what goes in it, how to write or generate one, and how to keep it accurate after each release.
Published · 7 min read
Stop maintaining separate docs copies for your site, AI tools, and search. Learn how an MDX documentation site generator publishes one source to every format.
How many copies of your docs exist right now? There's the site, and maybe a Markdown export someone made for an AI assistant, a JSON feed for in-app search, and a hand-written llms.txt. If each one is maintained separately, each one can be wrong on its own schedule. An mdx documentation site generator should solve that by treating MDX as the single source and everything else as build output. This article walks through how that works: write once in MDX, publish HTML for people, publish Markdown, JSON, and llms.txt for machines, and keep the source current when the product changes.
The official docs put it in one sentence: "MDX allows you to use JSX in your markdown content." Most of a docs page is prose, headings, lists, and code blocks, and Markdown feels more natural to type than HTML or JSX for those common things. When a page needs something Markdown can't express, such as tabs for three SDK languages, a callout, or an API parameter table, you drop in a component.
That split is why MDX suits developer docs. Writers stay in plain text and engineers can review a diff. Components carry the structure that plain Markdown loses.
A few things trip up teams coming from plain Markdown:
<img> becomes <img />.None of this is hard, but it should be caught by a build check, not by a reader.
MDX is not a rendering format. The core package describes itself plainly: "This package is a compiler that turns MDX into JavaScript." A site generator sits on top of that compiler. It reads your files, resolves components, builds navigation, and emits pages.
How good the output is depends on how much meaning the source carries. Some habits pay off in every format you publish later:
<Warning> or <Param> can be translated to other formats, but a styled <div> cannot.The website is still the main event. In Stack Overflow's 2025 Developer Survey, "Technical documentation is the most used resource for learning, with nearly 68% of respondents using it in the past year." People read your docs in a browser, so the HTML build has to be fast, navigable, and correct.
Publishing HTML from MDX is a build step, and you should treat it like any other build:
Whatever the HTML build knows about a page should come from the MDX file and the repository around it. That includes its title, its sections, and its place in the nav. The other formats get their information from the same place.
Human readers are no longer the only audience. Stack Overflow's 2025 survey found that 84% of respondents use or plan to use AI tools in their development process, up from 76% in 2024. A developer asking Claude, Cursor, or Copilot how to call your API is reading your docs secondhand. In the same survey, 46% of developers said they don't trust the accuracy of the output from AI tools, up from 31% the year before. Stale or badly parsed docs give them a reason not to.
Rendered HTML is a poor input for these tools. Navigation, scripts, and layout markup crowd out the content. Three extra outputs fix that.
Each page gets a clean Markdown version with components flattened into plain text equivalents. The llms.txt proposal suggests offering it at the same URL as the page, with .md appended or replacing the extension.
Consistency matters here. CommonMark exists because, in its words, "John Gruber's canonical description of Markdown's syntax does not specify the syntax unambiguously." Because nothing in Markdown counts as a syntax error, rendering differences often go unnoticed. Generated Markdown should follow one dialect and stay there.
Structured JSON gives programs the page as data: title, description, sections, and content. It can feed in-app help, search indexes, support tooling, and agents that need fields instead of a blob of text.
The proposal reads: "We propose adding a /llms.txt markdown file to websites to provide LLM-friendly content." The file can sit at the site root or at a path within it, and it acts as a curated index for the pages under that path.
Be honest with your team about its status. llms.txt is a proposal, not an official web standard. It is still changing. Search Engine Journal reported that Jeremy Howard "published a version 2 update to the spec on August 10." That update is the first revision since launch and adds standard ways for agents to discover Markdown versions of pages, including a rel="alternate" link with type="text/markdown".
A moving spec is one more reason to generate the file. If the build writes it, adopting a revision means changing the generator, not hand-editing an index.
This is the model behind Thally's Content Graph. You author in MDX, and it publishes HTML, Markdown, JSON, and llms.txt from that one source.
The usual failure is a second copy. Someone exports the docs to Markdown for a chatbot, or a support team pastes pages into a help center. Six weeks later the site says one thing and the copy says another, and nobody owns the difference.
The rule is simple: only MDX gets edited, and every other format is a build artifact. If the Markdown export is wrong, the fix is in the source or in the generator, never in the export.
Teams often ask how to publish machine-consumable docs without pushing writers into a complicated workflow, and how to balance startup speed with AI-readability, collaboration, and long-term governance. Single-source publishing answers most of that, because the machine formats cost writers nothing extra. When you compare tools, check for the following:
Git supplies the collaboration and most of the governance. When docs are MDX in a repository, a docs update can ride in the same pull request as the code or in a linked one, and the reviewer sees both diffs together.
A single source prevents the outputs from disagreeing with each other. It doesn't keep the source in step with the product. If the MDX is stale, you now publish the same stale answer in four formats, and AI tools repeat it with confidence.
Docs rarely go out of date because nobody cares. They drift because the change happened in one repository and the page lives in another. The hardest pages to catch are guides, tutorials, and support articles that mention a behavior without being "the docs for" that feature.
A workable pipeline, using CI you already have:
repository_dispatch event from the product repository to the docs repository.openapi.yaml, CI only has to rebuild when the spec changes.CI is good at noticing that something changed and running a job. It can't tell you which sentences in which pages are now wrong. That part needs impact analysis and a reviewer.
Thally automates that step by tracing each merged pull request to the affected pages and opening an update PR with the evidence attached. Nothing publishes until a person approves it.
Whichever way you run it, the update lands in the MDX and gets a human review. Then one build republishes the site, the Markdown, the JSON, and llms.txt together.
Published under the Thally editorial policy. Technical conformance is defined in the agent-readiness methodology.
Create a managed site, or use the open-source engine to run Thally yourself.