llms.txt for Nuxt.js
Three approaches for Nuxt.js: a static file in public/ (zero config), a Nitro server route for dynamic generation, or auto-generation from Nuxt Content documents.
Last updated:
Option 1: static file in public/
Nuxt copies everything in the public/ directory directly into the build output, served
at the root of your site. Place your file at public/llms.txt and it will be available at /llms.txt on every deployment target.
# Nuxt static file approach
#
# Place your file at: public/llms.txt
# Nuxt copies everything in public/ directly to the build output.
#
# Project structure:
# your-nuxt-app/
# ├── public/
# │ └── llms.txt ← add this
# ├── pages/
# └── nuxt.config.ts
#
# No configuration needed. Works with all deployment presets.
This approach requires no configuration and works identically across all Nitro presets: node-server, cloudflare-pages, vercel, netlify, and static.
Option 2: server API route
Create a file at server/routes/llms.txt.ts. Nuxt's Nitro engine maps files in server/routes/ directly to URL paths, so this file is served at exactly /llms.txt with no additional
routing config.
// server/routes/llms.txt.ts
// Nuxt server route — served at /llms.txt
export default defineEventHandler(() => {
const content = `# Your Site
> One-sentence description of what your site or product does.
## Documentation
- [Getting Started](https://yoursite.com/docs/start): Install and configure in minutes.
- [API Reference](https://yoursite.com/docs/api): Full endpoint catalog with examples.
## Product
- [Overview](https://yoursite.com/product): Core features and capabilities.
- [Pricing](https://yoursite.com/pricing): Plans and billing details.
## Optional
- [Changelog](https://yoursite.com/changelog): Release history.
- [GitHub](https://github.com/your-org/your-repo): Source code.
`;
setResponseHeader(event, 'Content-Type', 'text/plain; charset=utf-8');
setResponseHeader(event, 'Cache-Control', 'public, max-age=3600, stale-while-revalidate=86400');
return content;
});
Use setResponseHeader from the h3 library (bundled with Nuxt) to set the
correct Content-Type. Add a Cache-Control header so CDN edges cache the response and reduce origin load.
Option 3: Nuxt Content auto-generate
If you use Nuxt Content for documentation, you can query your
content collection and build the link list automatically. This ensures llms.txt stays
in sync with your docs without manual updates.
// server/routes/llms.txt.ts
// Auto-generate llms.txt from Nuxt Content documents
import { serverQueryContent } from '#content/server';
export default defineEventHandler(async (event) => {
// Query all docs; adjust collection name as needed
const docs = await serverQueryContent(event, '/docs')
.only(['title', 'description', '_path'])
.find();
const links = docs
.map((doc) => `- [${doc.title}](https://yoursite.com${doc._path}/): ${doc.description ?? ''}`)
.join('\n');
const body = [
'# Your Site',
'',
'> One-sentence description of your project.',
'',
'## Documentation',
'',
links,
].join('\n');
setResponseHeader(event, 'Content-Type', 'text/plain; charset=utf-8');
return body;
});
Adjust the query path (/docs) and field names to match your content structure. Run
the validator after deploys to catch any formatting regressions.
Nitro and deployment targets
- node-server — server routes run as a Node.js HTTP handler. Add a reverse proxy
(nginx/Caddy) cache rule for
/llms.txtto avoid hitting Node on every request. - cloudflare-pages — static files in
public/are served from Cloudflare's global CDN. Server routes become Pages Functions. See the Cloudflare guide for cache headers. - vercel — static files are Edge-cached automatically. Server routes become Vercel Serverless or Edge Functions depending on config.
- static (fully pre-rendered) — use the
public/static file approach; server routes are not available in purely static output.
Verify
After deploying, confirm the file is served correctly:
curl -I https://yoursite.com/llms.txt
# Expected:
# HTTP/2 200
# content-type: text/plain; charset=utf-8
curl https://yoursite.com/llms.txt | head -5
# Should print the first lines of your file Related guides
- How to create llms.txt — templates and checklist.
- llms.txt format reference — spec details.
- Vercel guide — deployment and cache headers.
- Cloudflare Pages guide — CDN config.
- Validator · Generator.