Repository navigation
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Description
Hello!
I'd like to propose the creation of a new docusaurus plugin for the creation of a llms.txt file.
As background, an llms.txt file is a way of co-locating needed information such that an LLM processing web pages is able to do so effectively and quickly. More information can be found on the llms.txt proposal website
The goal of this feature is to create a plugin that will generate this file for your docs.
Has this been requested on Canny?
No
Motivation
Having an llms.txt is a business need for our company, but I'm certain it would be helpful for others. I have already created a proof-of-concept plugin that writes the file, but I wanted to bring this to the community as a whole to see how the design could be improved and/or match others' use cases.
Additionally, many docs sites that I use and admire, such as dub.co and Cloudflare have already implemented llms.txt files. The former via Mintlify, the latter via a script.
Adding a new, optional plugin would give Docusaurus users the ability to opt-in to this new standard and allow their documentation to be accessed easily by LLM agents.
API design
The design is very similar to the sitemap plugin.
Configuration
ignorePatterns: ability to ignore specific paths from being included in thellms.txt.filename: ability to change the name and output path of thellms.txtfile.
I also considered configuration modifying the output of the file, but the llms.txt proposal is fairly set on the file structure so I declined to add that as a configuration option.
Have you tried building it?
Yes! I made a simple plugin that works for our use case. I would like to move it into this repo in order to make it available to other folks and to get feedback on the design. I feel it could be made much simpler and cleaner 😄
Self-service
- I'd be willing to contribute this feature to Docusaurus myself.
Activity
slorber commentedon Feb 6, 2025
We usually add to the Docusaurus core repo what we use on our own website. In this case it's not really a need we have, and adding this to core would put the burden on us to maintain over the long term. Many people want to add their plugin to core but we can't do that otherwise we'd end up with too many packages to maintain. I'd prefer to keep a lean core and keep this plugin in the community.
Also, I'm really not sure what this plugin adds to the regular
sitemap.xmlfile.I've checked your POC (prisma/web#6645), and as far as I understand it basically creates a list of links in Markdown format, but using a
.txtextension instead of Markdown (why not usellmt.md? 🤷♂ )Result: https://jharrell-llms-plugin.docs-51g.pages.dev/llms.txt
If we look at the Cloudflare example, it's also a list of links in Markdown format.
https://developers.cloudflare.com/llms.txt
I'm not sure how the h2 headings and occasional labels bring a lot of value to a regular sitemap.
Also your site recommends to link to html.md files, which you don't do here so the LLM would have to read an HTML page anyway. And we use MDX which means that this format is already less "LLM-friendly" that regular Markdown files which cannot contain React components that must be evaluated.
This site is linking to Markdown files, for example: https://docs.fastht.ml/llms.txt
This field is not my expertise but I don't find this proposal super convincing, it looks more like an early draft not covering edge cases than a spec. I don't think it should be added to Docusaurus core until the proposal gets more mainstream adoption and gets better documented. I'd also prefer if there was first a community implementation that satisfies early adopters. We can consider adding this to our repo later, but not as a first step. Until then I'm happy to support you developing a community plugin, so let me know if you are unable to achieve your needs.
I also wonder why it has to be a Docusaurus plugin. You could build a generic CLI tool that handles a full generic static deployment, looking for
sitemap.xmlor HTML files and creating LLM-friendly content.jharrell commentedon Feb 6, 2025
Thank you @slorber for the context. I don't disagree with your assessment, so I'll be closing this proposal.
For further information about why this over a sitemap etc there's this section of the proposed standard: https://llmstxt.org/#existing-standards
Thank you for the feedback, though. I'll continue to use my simplified solution.
DenhamPreen commentedon Feb 19, 2025
@jharrell could you share your "simplified solution", this does sound useful :)
jharrell commentedon Feb 19, 2025
@DenhamPreen sure. We're still iterating but here's the latest: https://github.com/prisma/docs/blob/22208d52e4168028dbbe8b020b10682e6b526e50/docusaurus.config.ts#L95
It generates an
llms-full.txtandllms.txt.Happy to chat further about it if I can help, my bsky account is in my GitHub profile 😊
feat: generate `llms-full.txt` and `llms.txt` files (#11)
generate llms.txt
slorber commentedon May 23, 2025
Considering the number of issues linking back to this one, I think we should consider implementing such a plugin in Docusaurus core, even though I'm still not super convinced by the usefulness of this file.
See some ideas on how this can be implemented here: #11191 (comment)
Note: many have copied the Prisma implementation, which works, but IMHO it's not ideal. We only generate
llms.txtin prod builds, so it's preferable to read the dirs and md source files there instead of insideloadContent()(which is more useful in dev to support hot reload).slorber commentedon May 23, 2025
Plugin design?
In my opinion, the problems we have when generating such llms file are:
We already exposed some metadata in the
postBuild({routes, routesBuildMetadata})attributes.We could easily enrich these with extra metadata that could be useful to generate the llms files (title, breadcrumb, other metadata).
Now, I'm not sure what kind of API the plugin could expose to define how Markdown files are grouped, and how we define an explicit order (does it even matter to LLMs?).
I guess we could provide a callback so that you can define the Markdown breadcrumb for each file, but that wouldn't allow you to order things:
Does it make sense?
It could be useful if the community provided concrete examples. Given a specific sample site, what kind of LLMS file do you expect it to output, and why?
The more diverse examples we have, the easier it becomes to design an API that suits all needs.
rachfop commentedon May 23, 2025
I also created a plugin: https://github.com/rachfop/docusaurus-plugin-llms
Devon-White commentedon May 23, 2025
I also started working on our own version of the plugin: signalwire/docs#290
I tried to mimic the behavior 1:1 with stripe where it also generates a .md version of every doc in the same route. So most routes you can append just
.mdand get the raw version of the doc.I also opted to do a
postBuildaction and converted the rendered HTML back to markdown. My decision to do this was because I didn't want to deal with components and partials in the initial content.I also added some built in rehype plugins to handle certain edge-cases that are known (like list in tables), and updating links to match the URL options that are set in the config (relative path, full URL, markdown generated doc)
I tried to make it as flexible as possible to work with any current Docusaurus website via the
contentSelectorsproperty.Example preview can be seen here: https://deploy-preview-290--signalwire-docs.netlify.app/llms.txt
Because its not pushed to our main site yet (also haven't implemented validate URL logic yet) don't use the full URLs, but just the relative portion (e.g: dont use
https://example/com/ai.mduse/ai.mdspaansba commentedon Jun 5, 2025
I think an official LLMs.txt plugin would be great. Here's how I believe it should work:
Proposed Build Process
1. llms.txt Generation
/docs,/blog, etc.) for .md filesdescriptionfield or a newllms_descriptionmetadata attribute for page descriptions/docs/llms.txt,/blog/llms.txt2. Raw Markdown File Generation
The llms.txt standard recommend providing an
.mdfor every page which the main llms.txt can link to.{page-url}.md/docs/integrations/react→/docs/integrations/react.md.mdfiles (if that is even possible)3. llms-full.txt Generation
/docs/llms.txt,/blog/llms.txtI would be happy to give it a shot.
Devon-White commentedon Jun 5, 2025
You may want to take a look at the plugin we just created, as it does a lot of what your looking for (link conversion, md file generation, ability to pass your own remark & rehype plugins to alter the generation, etc..)
The big difference for our approach is we work with the routes that are passed to us during the
postBuildcycle. We then useunifiedto help find the html file and convert it back to markdown. My decision to convert the rendered HTML back to markdown is to handle MDX partials and React components. Content may not be displayed properly since they are not rendered yet.I think the only things we don't currently have you are looking for is
llms-full.txtgeneration optionWith how the code is made, both of these options would be easy to add.
Feel free to open any feature request or issues at: https://github.com/signalwire/docusaurus-plugins
Tobbe commentedon Jun 9, 2025
@Devon-White your plugin works great! Thanks for sharing 🙏
Implemented here https://github.com/cedarjs/cedar/pull/118/files
Exposed at this url https://cedarjs.com/llms.txt
peterpeterparker commentedon Jul 2, 2025
Joining the party as well and sharing this in case it’s useful to anyone: I also followed the path of creating a custom plugin to generate /llms.txt and /llms-full.txt, tailored to my needs for Juno.
I may have taken a different approach by actually retro-engineering the Markdown files from the generated HTML files - i.e., once the site is generated, I filter the files to build a tree of the information I consider important for the language model, and then generate a Markdown file for each of those HTML files using Turndown. In addition, I also use JSDOM to extract the title and description for each of those links.
Worth noting: when I generate the Markdown files, I also manipulate the links to construct a navigation structure related to those files - i.e., Markdown files link to other Markdown files, not to the original HTML.
The solution definitely needs more iteration, and it’s not my most brilliant work - I left performance considerations aside and haven’t written any tests yet 😅 - but it’s a start.
You can find the plugin here 👉 https://github.com/junobuild/docs/blob/main/plugins/docusaurus.llms.plugin.ts
slorber commentedon Jul 2, 2025
Interesting blog post from a Sentry engineer implementing llms.txt: https://byk.im/posts/marking-it-up-and-down/
peterpeterparker commentedon Jul 7, 2025
So, in addition to the custom plugin I shared above, I’ve added a CI job that snapshots the generated
llms.txtfiles and commits any changes with the PR. It slows down a bit, but this way I can review the diff and make sure the LLMs still look good. No formal tests but, some sort of assertions. Long story short: if that could be useful to anyone in addition to the plugin too, here you go 👉 https://github.com/junobuild/docs/blob/main/.github/workflows/llms.ymlnicolasiscoding commentedon Jul 22, 2025
where did we end up with this?
Devon-White commentedon Oct 4, 2025
Additionally, for the plugin i created above, i have created a theme to add a
Copy Pagebutton with a drop down to ask about the contents directly to a LLM provider in their cloud chat. This is mimicking the behavior that we are beginning to see from big documentation providers like Mintlify.Example:
The copyButton will render on any page that has a MD file generated for it.
To accompany this, i also pushed a major upgrade for the plugin, which includes a overhaul of the config interface. For the most part its just a reorganization, but I also introduced
Sectionsas a feature. Sections allow you to specify exactly what docs are housed under a section. You will also have the ability to add descriptions, title names, and subsections in a section object.I also added the ability t add
attachedFileswhich will parse the contents of the file and create a markdown file with its contents inside of it. Helpful for items that are useful for llms, but not handy as a doc (example would be a OpenAPI spec)Right now these additions are on the
alphatagged release, just in case feedback is provided and changes are needed. Once its in a comfortable state for a time period, i will do the official release.The alpha packages however can be found here:
Plugin: https://www.npmjs.com/package/@signalwire/docusaurus-plugin-llms-txt/v/2.0.0-alpha.2
Theme: https://www.npmjs.com/package/@signalwire/docusaurus-theme-llms-txt/v/1.0.0-alpha.3
harupy commentedon Nov 5, 2025
@Devon-White Thanks for the plugin! It works like a charm: mlflow/mlflow#18676
slorber commentedon Feb 16, 2026
Another implementation for the Mastra docs site: https://www.lekoarts.de/how-to-add-llms-txt-to-docusaurus/
Tobbe commentedon Feb 16, 2026
I'm very happily using @Devon-White's plugin, but Lennat's blog post that @slorber links above has some additional tips and ideas that I'd like to try to implement. Thanks for sharing Sébastien!
peterpeterparker commentedon Apr 21, 2026
To follow-up on my previous post in this thread and sharing in case it’s useful to anyone: I've tackled a remaining todo and enhanced my custom docusaurus.llms.plugin.ts.
The plugin already generated
llms.txtand Markdown files, it now also hooks into the HTML source file to append a<link>alternate reference pointing to the corresponding.mdfile.For example
The idea came from a Reddit discussion and a blog post I stumbled upon, and I also noticed platforms like Vercel are also doing so in their documentation.
Hope that helps.
feat: adopt @signalwire/docusaurus-plugin-llms-txt (Phase 1) (#497)
danielcalvolopez commentedon Aug 28, 2026
Design proposal: official markdown output + llms.txt for Docusaurus
This is an attempt at the design questions @slorber posed upthread (May 23, 2025), including the concrete one: "Given a specific sample site, what kind of LLMS file do you expect it to output, and why?" It's also meant to clear the bar set when closing #11420 — lay out the possible choices and their tradeoffs before writing any implementation. The only code behind this is a small feasibility spike whose numbers show up in section 4. Happy to share it, but the point of this post is the design.
TL;DR
/docs/foo→/docs/foo.md), with llms.txt as a thin index over them. The twins are useful to any agent that fetches URLs today, whether or not the llms.txt spec ends up winning.markdownBreadcrumb(your sketch) becomes the escape hatch rather than the default.:::directives untransformed, and serialize the mdast through a component registry (known theme components get markdown equivalents, unknown ones unwrap to children and get counted in a build-time coverage report).@docusaurus/plugin-llms-txt, sitemap-stylepostBuildemission, docs metadata viaallContent, route metadata (sourceFilePath) as the uniform fallback. No core changes needed for v1.Acceptnegotiation stay out of core, since that's past the SSG boundary. The plugin emits files; hosting recipes cover negotiation, including theVary: Acceptcache-poisoning trap.1. Reframing: markdown pages first, llms.txt second
The skepticism in this thread ("not sure any crawler consumes it") is fair. llms.txt consumption by crawlers is genuinely unproven. But I'd argue the file is the least valuable part of this feature. What is consumed today, heavily, is plain markdown at predictable URLs: coding agents and chat assistants fetch docs pages mid-conversation, and what they currently get from a Docusaurus site is hydrated HTML — expensive in tokens, noisy, sometimes content-free without JS. Mintlify and Rspress ship markdown twins natively, Fumadocs documents it as a first-class recipe. Docusaurus is now the largest docs framework with nothing official.
So I'd flip the usual framing:
markdownPages— a.mdtwin per content route. Valuable on its own.llms.txt— an index of the twins (title + description per page). Nearly free once (1) exists.llms-full.txt— optional concatenation, opt-in, with a size warning.If llms.txt-the-spec dies, (1) still justifies the plugin. If it wins, Docusaurus is already compliant.
2. What docusaurus.io's llms.txt should look like, and why
Sections come from top-level sidebar categories, in sidebar order. Entries are
[title](twin-url): description, using metadata docs already have (title,description/excerpt). The reason to lean on sidebars: they're the only human-curated hierarchy that exists on every Docusaurus site, so reusing them means zero new curation burden, and the output mirrors what maintainers already consider the right reading order. Deeper nesting flattens into a breadcrumb prefix on the link title — which is where amarkdownBreadcrumbcallback could slot in as an override later.This covers all four problems enumerated in the May 23 sketch — which routes are listed (every content-plugin route not excluded), how routes group under headings (sidebar categories), how headings are ordered, and how links are ordered within each group (sidebar order, both levels) — by reusing the structure that already encodes the maintainer's answer to each.
Here's a trimmed version, with real titles and descriptions from
website/docs:A few decisions baked into this, all of them debatable:
.mdtwins, not the HTML pages. The file exists for agents; sending them to HTML defeats the purpose.##per top-level sidebar category, one section per additional docs instance/sidebar, and blog under Optional (the llms.txt convention is that## Optionalmarks skippable content).siteConfig.tagline/description, overridable.3. Per-page markdown twins
.md(/docs/installation→/docs/installation.md; a permalink ending in/maps to…/index.md). These are static files emitted next to the HTML inoutDir, so every host serves them with a sane content type without any configuration.# {title},> {description}, serialized body, nothing else. No frontmatter by default (agents read prose; the metadata they need is in llms.txt), with an option to include it.<link rel="alternate" type="text/markdown">would be nice, but a standalone plugin can't inject per-route head tags today, so I've flagged that as an open question rather than smuggling it into v1 scope. A "copy page as markdown" theme button is a natural follow-up once twins exist.4. The serialization core
This is the part the existing ecosystem hasn't solved, and the reason "just copy the sources" and "just convert the HTML" both disappoint:
mdx-code-blockfences,{#heading-ids}).The Sentry write-up shared earlier in this thread states the received wisdom: "we cannot go directly from MDX to Markdown, we had to render the HTML from MDX first and then convert it to Markdown, essentially doubling the work." I don't think that premise holds for Docusaurus. The mdast — after Docusaurus's own source preprocessors, before any rehype — still knows exactly what the author meant, and serializing from it is both direct and cheap.
So the proposal is to serialize from the mdast:
unwrapMdxCodeBlocks,admonitionTitleToDirectiveLabelfrom@docusaurus/utils). This is what makes patterns like<APITable>split across twomdx-code-blockfences parse correctly.:::noteis still a cleancontainerDirective.:::note/:::tip[Title], nested> **Warning: Title**), nesting preserved<Tabs>/<TabItem>**npm:** …)<details>/<Details><CodeBlock language title>```bash npm2yarn<DocCardList /><TOCInline />_*.mdx)APITable,BrowserWindow, …){expressions}, heading{#ids}The registry is the extension point: theme authors and sites register serializers for their own components, the same way
createSitemapItemscustomizes the sitemap.To sanity-check feasibility I ran the spike against six unmodified pages of
website/docs— the Tabs, Admonitions, and Code-blocks guides, thedocusaurus.config.jsAPI reference, the CLI reference, and the MDX-and-React guide as a worst case. The serializer produced zero leftover JSX/imports/directives, preserved every heading (e.g. 40/40 on the config API reference) and every table (including theAPITable-wrapped ones), retained ≥99% of visible text, and ran at 11–66ms per page. Unknown-component degradation behaved as designed on the React stress page: a custom<Highlight>unwrapped to its children, and a partial import surfaced in the coverage report instead of silently vanishing.To be upfront about what degrades: components whose content only exists at runtime (live demos,
BrowserOnly, code blocks built from JS expressions) fall back to their children or a recorded drop. The coverage report makes every such loss visible at build time instead of silent.Before/after excerpts from the spike (unmodified pages of
website/docs)From
markdown-features-tabs.mdx— anmdx-code-blocklive demo wrapping a theme component wrapping tabs:serializes to:
From
markdown-features-admonitions.mdx— nested admonitions with legacy titles:serializes to:
(The code-fence examples of these syntaxes on the same pages stay verbatim — the serializer only transforms live constructs.)
5. Plugin architecture
This matches the postBuild sketch from May 2025, and nothing here requires core changes:
@docusaurus/plugin-llms-txt) rather than a docs-plugin feature, because it has to see docs (multi-instance), blog, and pages uniformly.allContentLoaded: read docs/blog metadata and sidebars (for grouping and ordering) fromallContent.postBuild: serialize each route's source (route metadatasourceFilePathis the plugin-agnostic mapping), write twins + llms.txt intooutDir. This is exactly the sitemap plugin's emission pattern, including its hash-router guard. Source files are read atpostBuild, notloadContent, which matches the preference stated upthread: prod-only generation, no dev/hot-reload cost.Config sketch, kept small on purpose (every option should have to earn its place):
6. What stays out of core
Docusaurus is a static-site generator: it has no header or negotiation mechanism, and this design doesn't add one.
Accept: text/markdownnegotiation is a hosting concern, and a sharp-edged one — rewriting negotiated responses withoutVary: Acceptcache-poisons CDNs into serving markdown to browsers (or HTML to agents). The plugin's job ends at emitting correct static files. A documentation recipe per host (Vercel/Netlify/Cloudflare) can show optional negotiation configs with theVarywarning attached. Static.mdtwins deliberately don't need any of it.7. Testing and rollout
website/docspages with mechanical gates — zero MDX residue in output, heading/table/code-block counts preserved, visible-text retention ratio. All deterministic, no LLM in the loop.8. Open questions for maintainers
:::passthrough (round-trips into Docusaurus, unrenderable elsewhere)?source_url,last_updated)?<link rel="alternate" type="text/markdown">: worth a small core/theme hook, or defer?9. Prior art
@signalwire/docusaurus-plugin-llms-txt— postBuild HTML→markdown reconversion; most-installed; v2 in alpha since Nov 2025. Robust to unknown components, loses authored semantics.docusaurus-plugin-llms(rachfop) — MDX source processing with heuristic cleaning; actively maintained; open fidelity issues around JSX content, partials, paths.docusaurus-plugin-llms-txt(din0s) — single 2024 release.Happy to iterate on any section, generate the full llms.txt for docusaurus.io from a local build as a concrete artifact, or turn the serialization core into a PR once the team agrees on a direction. The spike (serializer + fixture checks) is small and I can share it as-is.