Generating a multilingual llms.txt in Astro A developer created a multilingual llms.txt generator for Astro sites using Content Collections and API routes. The implementation produces three endpoints—/llms.txt, /ja/llms.txt, and /llms-full.txt—from a single renderer, with language filtering and draft exclusion. The approach avoids manual upkeep by dynamically assembling the post list from the collection. llms.txt is a Markdown index for LLMs, placed at the site root. Where sitemap.xml is a machine-readable list of URLs, llms.txt describes — with one-line notes — what the site is and where to start reading. In Astro you can generate it from Content Collections as an API route, so the post list never has to be hand-maintained. This post is the minimum setup for a bilingual EN/JA site: emit /llms.txt , /ja/llms.txt and /llms-full.txt from one renderer. Up front: how much llms.txt actually helps AI-search traffic isn't a settled or measured thing yet. This is only about the implementation. Astro's file-based API routes return text when you drop a .txt.ts file under src/pages/ . Return a text/plain Response from a GET handler. python // src/pages/llms.txt.ts import type { APIContext } from "astro"; import { renderLlmsTxt } from "../lib/llmsTxt"; export async function GET context: APIContext { const body = await renderLlmsTxt { docLang: "en" } ; return new Response body, { status: 200, headers: { "Content-Type": "text/plain; charset=utf-8", "Cache-Control": "public, max-age=3600", }, } ; } The .txt.ts extension builds to the URL /llms.txt . Keep the assembly logic in src/lib/llmsTxt.ts and leave the route thin, so a per-language endpoint can reuse it. Get the post list with getCollection and lay it out on the fly. A hand-kept list goes stale — add a post, forget the index, and llms.txt drifts from the content. // src/lib/llmsTxt.ts excerpt export async function renderLlmsTxt opts: LlmsTxtOptions : Promise