Advanced

AI-ready content files(`llms.txt`)

Learn how to generate AI-ready content files using Nuxt Content and the Nuxt LLMs module.

LLMs Integration

The Nuxt Content module seamlessly integrates with 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 page collection to the LLMs module.

Setup Guide

  1. First, install the required module:
npm install nuxt-llms
# or
yarn add nuxt-llms
  1. Configure your nuxt.config.ts:
// 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!

Nuxt Content will automatically detect Nuxt LLMs module and will create a section to each page collection.

Custom Sections

The Content module enhances the LLMs module by adding two key options to control content generation:

  • contentCollection: Specifies which content collection to use as source
  • contentFilters: Defines filters to select specific content within the collection

When generating content, the module uses these options to fetch and process your content into LLM-friendly formats (llms.txt and llms_full.txt).

All you need is to add your custom sections to the llms.sections array and define the contentCollection and contentFilters for each section.

// 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',
    sections: [
      {
        title: 'Documentation',
        description: 'Technical documentation and guides',
        // Specify which content collection to use
        contentCollection: 'docs',
        // Filter content as needed
        contentFilters: [
          { field: 'extension', operator: '=', value: 'md' },
          // You can add more filters here
        ]
      },
    ],
  },
})
If there is no section defined with the contentCollection option, the module will add page collections to the LLMs module.

Content Filtering

You can use contentFilters to precisely control which content is included. Each filter consists of:

  • field: The content property to check
  • operator: Comparison operator (=, <>, >, <, LIKE, IN, NOT IN, IS NULL, IS NOT NULL, etc.)
  • value: The value to compare against

Example filters:

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%' },
]
Checkout the nuxt-llms documentation for more information on how to use the LLMs module.