1.1.0 • Published 4 months ago

eleventy-plugin-llms-txt v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

eleventy-plugin-llms-txt

An Eleventy plugin that generates a llms.txt file to expose your site's content to Large Language Models (LLMs) in a structured format.

Installation

npm install eleventy-plugin-llms-txt

Usage

Add the plugin to your Eleventy configuration file (.eleventy.js):

const llmsTxtPlugin = require('eleventy-plugin-llms-txt');

module.exports = function(eleventyConfig) {
  eleventyConfig.addPlugin(llmsTxtPlugin, {
    // options (optional)
  });
  
  // ... rest of your config
};

After building your site, a llms.txt file will be generated in your output directory (typically _site).

Options

The plugin accepts the following options:

OptionTypeDefaultDescription
outputPathString'llms.txt'Path to the output file (relative to the output directory)
collectionsArray['all']Collections to include in the output
excludeCollectionsArray[]Collections to exclude from the output
excludeContentTypesArray[]Content types to exclude
siteUrlString''Base URL of your site
includeContentBooleantrueWhether to include page content
maxContentLengthNumber10000Maximum length of content to include
dateFormatString'toISOString'Date format method to use
additionalMetadataArray[]Additional metadata fields to include
sortByDateBooleanfalseWhether to sort collection items by date
sortDirectionString'desc'Sort direction: 'desc' (newest first) or 'asc' (oldest first)

Example with options

eleventyConfig.addPlugin(llmsTxtPlugin, {
  outputPath: 'ai/llms.txt',
  collections: ['posts', 'pages'],
  excludeCollections: ['drafts'],
  siteUrl: 'https://example.com',
  maxContentLength: 5000,
  additionalMetadata: ['description', 'author'],
  sortByDate: true,
  sortDirection: 'desc' // 'desc' for newest first, 'asc' for oldest first
});

Output Format

The generated llms.txt file follows this format:

# Site Content for LLMs
# Generated: [timestamp]
# Site URL: [your site URL]

## Collection: [collection name]

### Page: [page title]
URL: [page URL]
Date: [page date]
Tags: [page tags]
[additional metadata fields]

Content:
[page content]

---

[next page...]

Why use this plugin?

LLMs like ChatGPT, Claude, and others can better understand and reference your website's content when it's presented in a structured format. The llms.txt file provides:

  1. Structured content: Organized by collections, pages, and metadata
  2. Clean text: HTML stripped and whitespace normalized
  3. Relevant metadata: Titles, URLs, dates, tags, and custom fields
  4. Efficient crawling: All content in one file for easy processing

License

MIT

1.1.0

4 months ago

1.0.0

4 months ago