How to add llms.txt to Gatsby
Gatsby copies /static to the site root at build time. That's where llms.txt lives. Alternatively, use a serverless function on Gatsby Cloud or Netlify.
Before you start
- ✓A Gatsby project (v3+)
- ✓Deploy host: Gatsby Cloud, Netlify, or any static host
- ✓An llms.txt body ready to drop in
Install in 3 steps
- 1
Add to /static
Place llms.txt in /static at the project root.
- 2
Or create a function
On Gatsby Cloud / Netlify, add src/api/llms.ts exporting a default handler that returns plain text.
- 3
Verify
Build, then curl the deployed URL.
Troubleshooting
Add /llms.txt to the gatsby-plugin-offline exclusion list and force a SW update.
Configure your CDN to serve text/plain without forced gzip, or rely on standard Accept-Encoding negotiation.
Common gotchas
- • Gatsby plugins (gatsby-plugin-offline) may cache the file — exclude /llms.txt from the SW
- • Make sure your CDN doesn't gzip text/plain into something AI crawlers don't accept
Generate your llms.txt in 30 seconds
Use the free OptimAIze generator, then follow the steps above to deploy on Gatsby.
Frequently asked questions
Does Gatsby 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 Gatsby 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.