---
title: "Markdown and llms.txt endpoints"
description: "Add alternate Markdown/MDX versions, llms.txt indexes, and llms-full.txt."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.klounge.kr/llms.txt
> Use this file to discover all available pages before exploring further.

# Markdown and llms.txt endpoints

Add the five endpoints that serve alternate Markdown/MDX versions, site and section `llms.txt` indexes, and `llms-full.txt`. The Nimbus integration must already be present in `astro.config.ts`.

## 1. Add alternate page versions

Create the clean Markdown version:

```ts title="src/pages/[...slug]/index.md.ts"
import { markdownRoute } from "@cloudflare/nimbus-docs/agent-endpoints";

export const prerender = true;
export const { GET, getStaticPaths } = markdownRoute();
```

Create the MDX source version:

```ts title="src/pages/[...slug]/index.mdx.ts"
import { markdownSourceRoute } from "@cloudflare/nimbus-docs/agent-endpoints";

export const prerender = true;
export const { GET, getStaticPaths } = markdownSourceRoute();
```

These two routes serve every collection, including docs versions, a blog at `/blog`, and API references. API pages have a `.md` version but no `.mdx` source. Pages in hidden versions have neither. Collections you add later need no new route files. To customize the output for some or all pages, see [Override a default](/ai/override-markdown).

Both routes must stay prerendered. The build fails if either one is rendered on request.

## 2. Add the site index

Create the site-wide discovery index:

```ts title="src/pages/llms.txt.ts"
import { llmsRoute } from "@cloudflare/nimbus-docs/agent-endpoints";

export const prerender = true;
export const { GET } = llmsRoute();
```

## 3. Add llms-full.txt

Create the file containing all discoverable documentation:

```ts title="src/pages/llms-full.txt.ts"
import { llmsFullRoute } from "@cloudflare/nimbus-docs/agent-endpoints";

export const prerender = true;
export const { GET } = llmsFullRoute();
```

## 4. Add section indexes

Create the route for paths such as `/writing/llms.txt`:

```ts title="src/pages/[section]/llms.txt.ts"
import { llmsSectionRoute } from "@cloudflare/nimbus-docs/agent-endpoints";

export const prerender = true;
export const { GET, getStaticPaths } = llmsSectionRoute();
```

Each `GET` returns `404` for an unknown section. Rendered on request, it returns a `500` without details when an index can't be read, and logs the error. To change what a route serves, see [Override a default](/ai/override-markdown#override-an-llmstxt-index).

Keep the `llms.txt` endpoints prerendered unless you deliberately want them rendered on request. The `agent-endpoints` helpers support either mode and require the Nimbus Astro integration. The build warns about every Markdown version or `llms.txt` index that no prerendered route generated, and names the route that serves it; ignore the warning for routes you render on request on purpose.

## Verify

Run a production build, then start Astro's production preview:

```sh
pnpm build
pnpm preview
```

In another terminal, replace `get-started` and `writing` with routes that exist in the project. If Astro has a deployment base, prefix each path with it:

```sh
curl --fail http://localhost:4321/get-started/index.md
curl --fail http://localhost:4321/get-started/index.mdx
curl --fail http://localhost:4321/llms.txt
curl --fail http://localhost:4321/llms-full.txt
curl --fail http://localhost:4321/writing/llms.txt
```

Each command must return content with a successful status. A `404` means the corresponding route file is missing. If the build reports an unprepared collection, wrap its Markdown loader with `withNimbusMarkdown()` as described in [Other collections](/writing/pages-and-routing#other-collections). If a section index is absent, confirm that the section has discoverable pages and appears in `/llms.txt`.

## Direct rendering

`renderEntryAsMarkdown()` and `getEntryMarkdown()` remain available for entry bodies that do not contain `<Render>`. Passing a body with `<Render>` throws. Use the endpoints above for alternate authored Markdown versions and `llms.txt` indexes. `getEntryMarkdown()` also loads API citation data and is intended for prerendered routes.

## Next steps

- [Understand docs for agents](/ai/docs-for-agents)
- [Customize generated Markdown](/configuration#customize-generated-markdown)
- [Configure custom content loaders](/writing/pages-and-routing#other-collections)

Source: https://docs.klounge.kr/ai/publish-markdown/index.mdx
