This plugin automatically generates LLMS text files (llms.txt
and llms-full.txt
) for VitePress projects.
It can be used to create useful metadata files and provide structured information for large language models (LLMs).
- β¨ Features
- π Installation
- π Usage
- βοΈ Configuration
- π‘ Examples
- π‘ Client Examples
- π¨βπ» Contribute
- Simple to use (no configuration required).
- lightweight and zero dependencies.
- Automatically Generates a
llms.txt
of all pages. - Automatically Generates a
llms-full.txt
of all pages. - Automatically Generates
.md
files for each page. - Supports Ignoring certain routes.
- Supports custom frontmatter addition.
- Supports transformation of page data via a callback.
- Supports for building only certain files.
- Generates a table of contents (TOC).
- Follows the https://llmstxt.org/ standard.
Install the plugin:
npm install vitepress-plugin-llmstxt
# or
pnpm install vitepress-plugin-llmstxt
# or
yarn add vitepress-plugin-llmstxt
# or
bun add vitepress-plugin-llmstxt
# or
deno add vitepress-plugin-llmstxt
Import and use the plugin in your VitePress configuration:
import { defineConfig } from 'vitepress';
import llmstxtPlugin from 'vitepress-plugin-llmstxt';
export default defineConfig({
vite: {
plugins: [llmstxtPlugin()],
},
});
This plugin requires no configuration, but if you need specific settings, it can be flexibly configured to suit any use case.
- π See d.ts
The plugin supports the following configuration options:
The base URL to use for generated links.
@example 'https://example.org'
Defaults to the server's origin if not specified.
An array of glob patterns to exclude from processing.
@example ["**/guide/api.md"]
Whether to generate the main llms.txt
file.
Defaults to true
.
If passed as an object, you can control additional options:
Controls the content of the table of contents inside the llms.txt
file.
'only-llms'
- Only the title with LLMs links'only-web'
- Only the title with web links'only-llms-links'
- Only the LLMs links'only-web-links'
- Only the web linkstrue
- Show bothfalse
- No index included
Whether to generate the extended llms-full.txt
file.
@default true
Whether to generate a .md
file for each route.
@default true
A callback to transform each page's data before writing it.
It receives:
{
page: LlmsPageData,
pages: LlmsPageData[],
vpConfig?: VPConfig,
utils: {
getIndexTOC: (type: IndexTOC) => string,
removeFrontmatter: (content: string) => string
}
}
You can use this to mutate page.content
, add or remove metadata, or conditionally skip pages.
import { defineConfig } from 'vitepress';
import llmstxtPlugin from 'vitepress-plugin-llmstxt';
export default defineConfig({
vite: {
plugins: [
llmstxtPlugin({
hostname: 'https://example.com',
ignore: ['*/api/**/*'],
llmsFile: {
indexTOC: 'only-llms',
},
llmsFullFile: true,
mdFiles: false,
transform: ({ page, pages }) => {
if (page.path === '/llms.txt') {
page.content = `Structured information designed to provide useful metadata to large language models (LLMs)\n\n` + page.content;
}
return page;
},
})
],
},
});
- π More
You can display your call information on the frontend. Here's an example:
<script setup>
import { computed } from 'vue'
import { getRouteData } from 'vitepress-plugin-llmstxt/client'
const llmsPath = computed(() => {
const llmsData = getRouteData()
return llmsData?.path
})
</script>
<template>
<div
class="llmstxt-section"
v-if="llmsPath"
>
<p class="outline-title">
LLM Resources
</p>
<ul>
<li>
<a
:href="llmsPath"
target="_blank"
class="VPLink link"
>
llms.txt
</a>
</li>
</ul>
</div>
</template>
<style>
.llmstxt-section {
margin: 25px 0px 5px 0px;
}
.llmstxt-section li {
margin: 5px;
}
.llmstxt-section a {
font-size: small;
margin: 0;
color: var(--vp-c-text-2);
transition: color 0.5s;
}
.llmstxt-section a:hover {
color: var(--vp-c-text-1);
transition: color 0.25s;
}
</style>
import DefaultTheme from 'vitepress/theme'
import { h } from 'vue'
import Llmstxt from './components/llmstxt.vue'
/** @type {import('vitepress').Theme} */
export default {
extends : DefaultTheme,
Layout( ) {
return h( DefaultTheme.Layout, null, { 'aside-outline-after': () => h( Llmstxt ) } )
},
}
- π More
vitepress-plugin-llmstxt
is an open source project and its development is open to anyone who wants to participate.
- π Report issues
- π Pull request
- βοΈ Star the repository
- β€οΈ Support
- π See code