Nuxt LLMs module
The Nuxt Content module integrates nuxt-llms to prepare your content for Large Language Models (LLMs). When nuxt-llms is detected, Content module automatically extends the LLMs module and inject collections of type page to the LLMs module.🚀
Setup
Install the required module
npm install nuxt-llms
Configure your nuxt.config.ts
export default defineNuxtConfig({
modules: ['@nuxt/content', 'nuxt-llms'],
llms: {
domain: 'https://your-site.com',
title: 'Your Site Name',
description: 'A brief description of your site',
},
})
That's it 🚀 /llms.txt file is automatically generated and pre-rendered.
Raw markdown access
When nuxt-llms is enabled, Nuxt Content also exposes a raw markdown endpoint so you can stream LLM-ready source files without going through the full rendering pipeline.
- Endpoint:
/raw/<content-path>.md(use the same path as the page URL, drop trailing/index, and keep the.mdextension), returningtext/markdown; charset=utf-8. - Scope: only
pagecollections are included; exclude specific collections withllms.contentRawMarkdown.excludeCollections. Setllms.contentRawMarkdown = falseto disable the endpoint entirely. - Output: if the requested document is missing a top-level heading or description, the route prepends the title and description to the markdown body before returning it.
- llms.txt links: document links generated in
llms.txtare automatically rewritten to the/raw/...mdendpoint (unless the collection is excluded or the feature is disabled) so agents fetch compact markdown instead of full HTML, reducing token usage and improving response speed. Control this withllms.contentRawMarkdown.rewriteLLMSTxt(defaults totrue).
export default defineNuxtConfig({
modules: ['@nuxt/content', 'nuxt-llms'],
llms: {
contentRawMarkdown: {
// Optional: prevent specific page collections from being exposed
excludeCollections: ['blog'],
// Optional: keep llms.txt links pointing to rendered pages
rewriteLLMSTxt: false,
},
},
})
Sections
When generating content, you can create custom sections to process your content into LLM-friendly formats.
You can create custom sections to the llms.sections array and define the contentCollection and contentFilters option for each section.
contentCollection option, the module will only add page collections to the LLMs module.contentCollection
This option specifies which content collection to use as source.
export default defineNuxtConfig({
llms: {
sections: [
{
title: 'Documentation',
description: 'Technical documentation and guides',
contentCollection: 'docs',
},
],
},
})
contentFilters
This options defines filters to select specific content within the collection.
You precisely control which content is included. Each filter consists of:
field: The content property to checkoperator: Comparison operator (=,<>,>,<,LIKE,IN,NOT IN,IS NULL,IS NOT NULL, etc.)value: The value to compare against
export default defineNuxtConfig({
llms: {
sections: [
{
title: 'Documentation',
description: 'Technical documentation and guides',
contentCollection: 'docs',
contentFilters: [
// Only include markdown files
{ field: 'extension', operator: '=', value: 'md' },
// Only include published content
{ field: 'draft', operator: '<>', value: true },
// Filter by directory
{ field: 'path', operator: 'LIKE', value: '/guide%' },
]
},
],
},
})