How to add llms.txt to Astro
Astro serves anything in /public unchanged. Either drop llms.txt there or use an endpoint for dynamic content.
Before you start
- ✓An Astro project (static or SSR adapter)
- ✓An llms.txt body — static file or imported module
Install in 3 steps
- 1
Static option
Place llms.txt in /public. Astro copies it untouched at build.
- 2
Dynamic option
Create src/pages/llms.txt.ts exporting a GET that returns new Response(content, { headers: { 'Content-Type': 'text/plain' } }).
- 3
Verify
Build and preview. Confirm headers.
Troubleshooting
Set prerender = true in the endpoint to render at build and avoid runtime cost.
Confirm /public is part of your build output — some custom Astro configs override the default.
Common gotchas
- • If you're on an SSR adapter, set prerender = true for the endpoint to avoid runtime cost
Generate your llms.txt in 30 seconds
Use the free OptimAIze generator, then follow the steps above to deploy on Astro.
Frequently asked questions
Does Astro need both llms.txt and robots.txt?
Yes. robots.txt grants crawler permission; llms.txt curates which pages matter. Together they form the minimum AI-search setup on any Astro site.
Will adding llms.txt slow down my site?
No. It's a tiny static text file fetched once and cached aggressively. Page-load impact is effectively zero.
How often should I update llms.txt?
Whenever your canonical content set changes — new docs section, new product line, new pricing page. A monthly review is a sensible cadence for most sites.
Can I see whether AI engines read my llms.txt?
Check your server logs for user agents like GPTBot, ClaudeBot, PerplexityBot, and Google-Extended hitting /llms.txt. Most sites see traffic within days of publishing.