How to Add llms.txt to an Astro Site
Astro is a natural fit for a llms.txt file. Because you own the build, you can either drop a static file into public/ or generate the file from your content collections with a file-based endpoint. Both land at your root; here is how to do each.
Generate the content first
Before wiring up either method, generate the Markdown. Our tool reads your live pages and drafts a clean, well-formed llms.txt. Enter your domain, review, and adjust before committing.
Generate your file:
Option 1: A static file in public/
Everything in Astro's public/ directory is copied straight into the build root without processing. Create public/llms.txt with the standard Markdown structure:
# Your Site or Company > One sentence describing what this Astro > site publishes and who reads it. ## Docs - [Guides](https://yourdomain.com/guides): How-tos. - [Reference](https://yourdomain.com/reference): Details. ## Content - [Blog](https://yourdomain.com/blog): Articles. - [Tags](https://yourdomain.com/tags): Topics. ## Site - [About](https://yourdomain.com/about): The story. - [Contact](https://yourdomain.com/contact): Get in touch.
Commit, build, deploy. This is the least-effort option and works with every Astro output mode.
Option 2: A generated endpoint
If you would rather have the file build itself from your content, use a file-based endpoint. Create src/pages/llms.txt.ts and export a GET handler:
// src/pages/llms.txt.ts
import { getCollection } from "astro:content";
export async function GET() {
const posts = await getCollection("blog");
const lines = [
"# Your Site or Company",
"",
"> One sentence summary.",
"",
"## Blog",
...posts.map(
(p) => `- [${p.data.title}](https://yourdomain.com/blog/${p.slug})`
),
];
return new Response(lines.join("\n"), {
headers: { "Content-Type": "text/plain; charset=utf-8" },
});
}Astro maps llms.txt.ts to the /llms.txt route. In a static build this renders once at build time; every new post appears automatically on the next deploy. Keep the list curated — quality over exhaustiveness.
Build and hosting notes
Astro's default static build writes both approaches into dist/, which your host serves from the root. On Netlify, Vercel, Cloudflare Pages, or GitHub Pages, no redirects or rewrites are needed. If you use output: "server" with an adapter, the endpoint runs per request instead — useful if you want the file to reflect data that changes between deploys, at the cost of a runtime.
Verify it works
Open the URL
Visit https://yourdomain.com/llms.txt and confirm you see plain-text Markdown rather than a styled HTML page.
Check headers
curl -I to confirm a 200 with Content-Type: text/plain. The public file sets this automatically; the endpoint sets it via your Response header.
Validate the links
Every URL in the file must resolve to a live page. If you generated the file, double-check the slug construction.
Run a visibility check
Use our AI Visibility tool to confirm the file is reachable and parseable from outside your build.
Frequently Asked Questions
public/ folder or an endpoint — which should I pick?
Use public/ when the content is fixed and you are happy editing it by hand; the file is copied verbatim into your build with zero code. Use an endpoint (src/pages/llms.txt.ts) when you want Astro to assemble the file from your content collections or frontmatter so it updates itself as you add pages.
How do I name the endpoint so it serves at /llms.txt?
Create src/pages/llms.txt.ts and export a GET function. Astro maps that filename to the /llms.txt route and serves whatever your Response returns, so set the Content-Type header to text/plain.
Does this work for a fully static Astro build?
Yes. Both approaches work with the default static output. The public/ file is copied as-is, and a GET endpoint with no server-only logic is rendered to a static /llms.txt at build time. If your endpoint depends on request data you would need an adapter with server output.
Will my host serve the file at the root?
Yes. Static hosts like Netlify, Vercel, Cloudflare Pages, and GitHub Pages serve the contents of Astro's dist/ from the deployment root, so both methods produce yourdomain.com/llms.txt with no extra configuration.
Does an llms.txt guarantee AI systems will use my content?
No. As of mid-2026 llms.txt is a proposed, advisory standard with no enforcement, and support varies across AI systems. There is no guarantee a given model will fetch or use your file. It is a sensible, low-effort signal rather than a guarantee.
Generate Your llms.txt for Astro
Enter your domain and get Markdown to drop into public/ or feed into a generated endpoint.