> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# LLM-Ready Content

**Publié le** : 2026-11-30
**Catégorie** : Advanced

Serve your content to AI assistants in Markdown: an `llms.txt` index, an `llms-full.txt` document, a `.md` version of each article and page, and Markdown on the page URL itself when a client asks for it in its `Accept` header. Lynkow generates all of it from your published content.

> **Reference** - This guide is a tutorial. For exhaustive, always-current signatures and field lists, see the auto-generated reference:
> 
> - SDK: [`SeoService`](/sdk/services/sdk-seo-service)
> - API: [Storefront: SEO](/storefront-api/storefront-seo)

## Prerequisites

- A Lynkow client in `@/lib/lynkow` ([Add Lynkow to an Existing Project](/sdk/getting-started/existing-project))
- llms.txt turned on: in the dashboard, **Settings > SEO > Robots and AI**, switch **Enable llms.txt generation**. While it is off, every call in this guide fails with a 404.
- Next.js 16 for the content negotiation of section 4

## What Lynkow generates

| SDK call | Your URL | Content |
| --- | --- | --- |
| `lynkow.seo.llmsTxt()` | `/llms.txt` | Index: site name, description, links to every article and page |
| `lynkow.seo.llmsFullTxt()` | `/llms-full.txt` | The full Markdown of every article and page in one document |
| `lynkow.seo.getMarkdown(path)` | `/{path}.md` | One article, page or category index as Markdown |


```markdown
# My Tech Blog

> A blog about web development and developer tools.

## Blog
### Tutorials
- [Getting Started with Next.js](https://example.com/tutorials/getting-started-nextjs.md): Build your first Next.js app.

## Products
- [Linen Shirt](https://example.com/products/linen-shirt)

## Pages
- [About Us](https://example.com/about.md): Our team and mission.
```

Links are absolute URLs on the site's domain. Articles and pages link to their `.md` version. On a site with a product catalog, `## Products`, `## Product categories` and `## Collections` sit between the articles and the pages, and link to the page itself: commerce pages have no Markdown version. In both files:

- a commerce line never carries a price or a stock level,
- an article, page, product, category or collection marked noindex is left out,
- the sitemap settings do not apply: a commerce type excluded from the sitemap is still listed.

## 1. Serve llms.txt and llms-full.txt

```typescript
// app/llms.txt/route.ts
import { lynkow } from '@/lib/lynkow'

export async function GET() {
  const body = await lynkow.seo.llmsTxt()
  return new Response(body, {
    headers: {
      'Content-Type': 'text/plain; charset=utf-8',
      'Cache-Control': 'public, s-maxage=86400',
    },
  })
}
```

`app/llms-full.txt/route.ts` is the same file with `lynkow.seo.llmsFullTxt()`. That document can weigh hundreds of KB, so keep the cache. To refresh both on publish, see [Webhooks & Cache Revalidation](/sdk/advanced/webhooks-revalidation).

### With `@lynkow/next`

`textRoute` from `@lynkow/next/server` caches the read and rewrites the absolute URLs to your `siteUrl`, so a copy served from localhost or a preview deployment links to itself. It answers 404 instead of throwing when llms.txt is turned off, which keeps a prerendered build from failing.

```typescript
// app/llms.txt/route.ts
import { TEXT } from '@lynkow/next/server'
import { server } from '@/lib/server' // your createLynkowServer() instance

export const revalidate = 3600
export const GET = server.textRoute((client, options) => client.seo.llmsTxt(options), TEXT)
```

## 2. One file per locale

```typescript
// app/[locale]/llms.txt/route.ts
import { isLynkowError } from 'lynkow'
import { lynkow } from '@/lib/lynkow'

export async function GET(
  _request: Request,
  { params }: { params: Promise<{ locale: string }> }
) {
  const { locale } = await params
  try {
    const body = await lynkow.seo.llmsTxt({ locale })
    return new Response(body, {
      headers: { 'Content-Type': 'text/plain; charset=utf-8' },
    })
  } catch (error) {
    if (isLynkowError(error) && error.status === 404) {
      return new Response('Not Found', { status: 404 })
    }
    throw error
  }
}
```

- `llmsTxt()` and `llmsFullTxt()` read the locale from their `locale` option only. The client's locale is ignored, so a call without the option returns the default locale's file.
- On a multi-language site, a locale the site does not enable answers 404. A single-language site serves its one file for any locale.
- Each locale's file lists the entries written or translated in that locale, with their names and URLs in it. A product hidden in a locale is left out of that locale's file.

With `@lynkow/next`, pass the route's locale explicitly: `server.textRoute((client, options, locale) => client.seo.llmsTxt({ ...options, locale }), TEXT)`.

## 3. Markdown version of a page

`getMarkdown()` takes the public path without `.md` and appends it. Pass an article's `path` or a page's `publicPath`: both already carry the locale prefix on a multi-language site.

```typescript
// app/md/[...path]/route.ts
import { isLynkowError } from 'lynkow'
import { lynkow } from '@/lib/lynkow'

export async function GET(
  _request: Request,
  { params }: { params: Promise<{ path: string[] }> }
) {
  const { path } = await params
  try {
    const markdown = await lynkow.seo.getMarkdown('/' + path.join('/'))
    return new Response(markdown, {
      headers: {
        'Content-Type': 'text/markdown; charset=utf-8',
        'Cache-Control': 'public, s-maxage=3600',
        Vary: 'Accept',
      },
    })
  } catch (error) {
    if (isLynkowError(error) && error.status === 404) {
      return new Response('Not Found', { status: 404 })
    }
    throw error
  }
}
```

A path that resolves to nothing, or to a product, category or collection, throws a `LynkowError` with status 404 ([Error Handling](/sdk/advanced/error-handling)).

## 4. `.md` URLs and content negotiation

The proxy below sends two kinds of request to the route handler of section 3:

- `/blog/my-article.md`, the URL `llms.txt` links to,
- `/blog/my-article` with an `Accept` header that prefers `text/markdown` to `text/html`.

```typescript
// proxy.ts
import { NextResponse, type NextRequest } from 'next/server'
import { markdownProxy } from '@lynkow/next/proxy'

export function proxy(request: NextRequest) {
  const { pathname } = request.nextUrl

  if (pathname.endsWith('.md')) {
    const url = request.nextUrl.clone()
    url.pathname = `/md${pathname.slice(0, -3)}`
    return NextResponse.rewrite(url)
  }

  // Keep llms.txt, robots.txt and sitemaps out of the negotiation.
  if (/\.(txt|xml)$/.test(pathname)) return NextResponse.next()

  return markdownProxy(request) ?? NextResponse.next()
}

export const config = {
  matcher: ['/((?!_next|favicon.ico|md|api).*)'],
}
```

`markdownProxy()` parses q-values and wildcards, keeps HTML on a tie, and returns `null` when the client prefers HTML. On a rewrite it sets `Vary: Accept` on the response and `X-Forwarded-Accept: text/markdown` on the request. Its options:

- `mdPathPrefix`: where the route handler is mounted, `'/md'` by default.
- `setVary: false`: skip `Vary` when your CDN sets it.
- `setForwardedAccept: false`: skip the forwarded header.

Set `Vary: Accept` from the proxy or a route handler, as above. Next.js replaces the `Vary` header of App Router pages, so setting it from `next.config` headers has no effect there.

`@lynkow/next` requires Next.js 16, where the file is `proxy.ts` and the export `proxy`. On Next.js 14 or 15, stay on `lynkow` 1.59, which ships the same helpers as `lynkow/middleware/next`, and use `middleware.ts` with a `middleware` export.

### Leave commerce URLs out

The helper also rewrites a product URL, which then answers 404. To serve the HTML page to such a client, skip your commerce prefixes:

```typescript
const COMMERCE_PREFIXES = ['/products', '/product-categories', '/collections']

const isCommerce = COMMERCE_PREFIXES.some(
  (prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)
)
if (isCommerce) return NextResponse.next()
```

These are the default prefixes. A site can change them, and a multi-language site serves its other locales under the locale prefix with translated segments (`/fr/produits/...`): see [Public URLs and routes](/sdk/features/commerce-products#public-urls-and-routes).

## 5. Discovery and testing

Crawlers look for `/llms.txt` at the site root. When llms.txt is on, the `robots.txt` Lynkow generates also disallows the llms files for Googlebot and Bingbot, so they stay out of search results ([SEO & Analytics](/sdk/media-seo/seo-analytics)).

```bash
curl -s http://localhost:3000/llms.txt
curl -s http://localhost:3000/fr/llms.txt
curl -s http://localhost:3000/blog/my-article.md
curl -si -H 'Accept: text/markdown' http://localhost:3000/blog/my-article   # text/markdown, Vary: Accept
curl -si -H 'Accept: text/html' http://localhost:3000/blog/my-article       # text/html
```

## Next Steps

- [Instant Search](/sdk/features/search) - add a search API that llms.txt advertises to AI agents
- [Webhooks & Cache Revalidation](/sdk/advanced/webhooks-revalidation) - refresh these files on publish
- [SEO & Analytics](/sdk/media-seo/seo-analytics) - sitemap, robots.txt and meta tags