Add your pages to the sitemap and llms.txt

Two helpers list your published pages: floconSitemap() for sitemap.ts and floconLlmsTxt() for llms.txt. Both come from @flocon-ai/next and use getAllPages().

Drafts are never listed. A page scheduled for later is not listed until its publish date.

Give your URL rule

Both helpers take a url function. It gets { locale, path } and returns the full URL of the page on your website.

  • locale is the page locale, like en or fr.
  • path starts with a slash, like /guides/seo.
  • Flocon AI imposes no URL rule. Build the URL the way your website does.

sitemap.ts

Create app/sitemap.ts:

import { floconSitemap } from "@flocon-ai/next"

export const dynamic = "force-dynamic"

export default function sitemap() {
return floconSitemap({
  url: ({ locale, path }) => `https://example.com/${locale}${path}`,
})
}

floconSitemap() returns an array in the Next.js sitemap format. Each entry has:

  • url
  • lastModified (the page updatedAt)
  • alternates.languages: one URL per locale where the page exists (hreflang)

To add your own pages, spread the result in your array.

llms.txt

Create app/llms.txt/route.ts:

import { floconLlmsTxt } from "@flocon-ai/next"

export const dynamic = "force-dynamic"

export async function GET() {
const text = await floconLlmsTxt({
  url: ({ locale, path }) => `https://example.com/${locale}${path}`,
})
return new Response(text, {
  headers: { "Content-Type": "text/plain; charset=utf-8" },
})
}

floconLlmsTxt() returns text with one Markdown link per published page:

- [Page title](https://example.com/en/guides/seo)
- [Titre de la page](https://example.com/fr/guides/seo)

getAllPages()

Use it when you need the list yourself. It returns the published pages, without their blocks.

import { getAllPages } from "@flocon-ai/next"

const pages = await getAllPages()

Each item has:

  • locale
  • path
  • title
  • updatedAt
  • alternates: the other locales where the same path is published, like ["fr"]

It throws an error if the API call fails.

Use dynamic rendering. The helpers read your pages on each request. This is why the examples set dynamic = "force-dynamic". Without it, Next.js may build the file once and a new page will not show up.

Environment

These helpers run on the server only. They read your read token from FLOCON_TOKEN.

Updated