llms.txt

Expose your documentation as LLM-friendly text files.

Installation

This plugin is included in fumapress.

Enable the plugin in your Fumapress config:

press.config.tsx
import { defineConfig } from "fumapress";
import { llmsPlugin } from "fumapress/plugins/llms.txt";

export default defineConfig({
  // ...
})
  .plugins(llmsPlugin());

The plugin creates:

  • /llms.txt: an index of your documentation pages.
  • /llms-full.txt: a combined text export of all pages.
  • /*.md: a markdown version for each page.

It also adds the markdown URL to docs pages, so layouts can show a "Copy Markdown" or markdown link when supported.

Options

getLLMText

By default, the plugin asks your configured adapters for each page's plain text content. If your content source does not expose text through an adapter, define getLLMText manually:

press.config.tsx
import { defineConfig } from "fumapress";
import { llmsPlugin } from "fumapress/plugins/llms.txt";

export default defineConfig({
  // ...
}).plugins(
  llmsPlugin({
    getLLMText(page) {
      return `# ${page.data.title} (${page.url})

${page.data.description ?? ""}`;
    },
  }),
);

Return undefined from getLLMText to exclude a page from /llms-full.txt.

routes

By default, only pages of your content source get a Markdown version. With routes: "all", every page created with createPage() gets one too, like src/pages/index.tsx or blog pages:

press.config.tsx
import { defineConfig } from "fumapress";
import { llmsPlugin } from "fumapress/plugins/llms.txt";

export default defineConfig({
  // ...
}).plugins(llmsPlugin({ routes: "all" }));

A page defines its Markdown form by calling asMarkdown() from fumapress/markdown, pages that don't respond 404. Static pages are pre-rendered into .md files, so they work in static mode too. Dynamic pages are rendered on request, so their Markdown can change over time like the page itself.

src/pages/index.tsx
import { asMarkdown, md } from "fumapress/markdown";

export default function Page() {
  if (asMarkdown()) {
    return md`
# My Site

Welcome! Read the [docs](/docs).
    `;
  }

  return <main>...</main>;
}

autoRedirect

When a request prefers Markdown in its Accept header (e.g. from an AI agent), the plugin serves the page's Markdown version at the original URL. Enabled by default, ignored in static mode since it requires a server:

press.config.tsx
llmsPlugin({ autoRedirect: false });

Last updated on

On this page