GitHub - okineadev/vitepress-plugin-llms: 📜 A VitePress plugin for generating LLM-friendly documentation
Extracto
📜 A VitePress plugin for generating LLM-friendly documentation - okineadev/vitepress-plugin-llms
Resumen
Resumen Principal
El vitepress-plugin-llms emerge como una solución innovadora y esencial para optimizar la documentación de proyectos web construidos con VitePress, haciéndola directamente consumible y altamente eficiente para los Modelos de Lenguaje Grandes (LLMs). Su propósito central es cerrar la brecha entre la documentación tradicional, a menudo "pesada y desordenada" para los LLMs, y un formato de Markdown puro y estructurado que estos modelos pueden procesar con mayor eficacia. La integración es sencilla, requiriendo una instalación npm y una configuración mínima en vitepress/config.ts, y funciona de manera autónoma sin necesidad de ajustes adicionales en la mayoría de los casos. Este plugin genera automáticamente versiones amigables para LLMs de cada página de la documentación, compilándolas en archivos clave como llms.txt (con enlaces estructurados) y llms-full.txt (con todo el contenido consolidado), siguiendo el estándar llmstxt.org para asegurar una comprensión óptima por parte de la IA. Además, ofrece herramientas para un control granular del contenido, permitiendo definir qué secciones son exclusivas para LLMs o excluidas de ellos, lo que es crucial para la precisión y relevancia de la información procesada por la IA.
Elementos Clave
- Generación Automatizada y Estructurada para LLMs: El
vitepress-plugin-llmstransforma de manera automática la documentación existente de VitePress en formatos optimizados para Modelos de Lenguaje Grandes (LLMs). Esto incluye la creación de archivos.mdindividuales para cada página, unllms.txtcon enlaces estructurados y unllms-full.txtque compila todo el contenido en un único archivo. Esta estructura no solo facilita el procesamiento, sino que también se adhiere al estándar **`llmstxt.
Contenido
📦 Installation
npm install vitepress-plugin-llms --save-dev
🛠️ Usage
Add the Vite plugin to your VitePress configuration (.vitepress/config.ts):
import { defineConfig } from 'vitepress' import llmstxt from 'vitepress-plugin-llms' export default defineConfig({ vite: { plugins: [llmstxt()], }, })
Now, thanks to this plugin, the LLM version of the website documentation is automatically generated
Note
For repositories with documentation in other languages: Please do not use this plugin, only English documentation is enough for LLMs.
Tip
You can add 📋 Copy as Markdown and 📥 Download as Markdown buttons for each page so that visitors can copy the page in Markdown format with just one click!
First, register a global component with buttons in docs/.vitepress/theme/index.ts:
import DefaultTheme from 'vitepress/theme' import type { Theme } from 'vitepress' import CopyOrDownloadAsMarkdownButtons from 'vitepress-plugin-llms/vitepress-components/CopyOrDownloadAsMarkdownButtons.vue' export default { extends: DefaultTheme, enhanceApp({ app }) { app.component('CopyOrDownloadAsMarkdownButtons', CopyOrDownloadAsMarkdownButtons) }, } satisfies Theme
And tell VitePress to use an additional Markdown plugin that will insert them:
import { defineConfig } from 'vitepress' import { copyOrDownloadAsMarkdownButtons } from 'vitepress-plugin-llms' export default defineConfig({ // ... markdown: { config(md) { md.use(copyOrDownloadAsMarkdownButtons) }, }, })
✅ Good practices
1. Use description in the pages frontmatter
Typically, the list of pages in llms.txt is generated like this:
- [Tailwind v4](/docs/tailwind-v4.md)
As you can see, it's not very clear what's on this page and what it's for
But you can insert description in frontmatter in the docs/tailwind-v4.md file:
--- description: How to use shadcn-vue with Tailwind v4. --- ...
And the link in the generated llms.txt will display the page description:
- [Tailwind v4](/docs/tailwind-v4.md): How to use shadcn-vue with Tailwind v4.
Plugin Configuration
Note
In most cases you don't need any additional configuration because everything works out of the box, but if you do need to customize it, please see your IDE hints or see src/types.d.ts or
Extended markup for content management
Embedding content specifically for LLMs with <llm-only> tag
You can add a content that will be visible in files for LLMs, but invisible to humans, this can be useful for setting special instructions like "Refer to #basic-queries for demonstrations", "NEVER do ....", "ALWAYS use ... in case of ..." etc.
To do this, you need to wrap content with the <llm-only> tag:
<llm-only> ## Section for LLMs This content appears only in the generated LLMs files without the `<llm-only>` tag </llm-only>
Or
Check out the Plugins API Guide for documentation about creating plugins. <llm-only>Note for LLM...</llm-only>
Excluding content for LLMs with the <llm-exclude> tag
You can add a content that will be visible in files for humans, but invisible to LLMs, opposite of <llm-only>:
<llm-exclude> ## Section for humans This content will not be in the generated files for LLMs </llm-exclude>
Or
Check out the Plugins API Guide for documentation about creating plugins. <llm-exclude>Note only for humans</llm-exclude>
🚀 Why vitepress-plugin-llms?
LLMs (Large Language Models) are great at processing text, but traditional documentation formats can be too heavy and cluttered. vitepress-plugin-llms generates raw Markdown documentation that LLMs can efficiently process
The file structure in .vitepress/dist folder will be as follows:
📂 .vitepress/dist
├── ...
├── llms-full.txt // A file where all the website documentation is compiled into one file
├── llms.txt // The main file for LLMs with all links to all sections of the documentation for LLMs
├── markdown-examples.html // A human-friendly version of `markdown-examples` section in HTML format
└── markdown-examples.md // A LLM-friendly version of `markdown-examples` section in Markdown format
✅ Key Features
- ⚡️ Easy integration with VitePress
- ✅ Zero config required, everything works out of the box
- ⚙️ Customizable
- 🤖 An LLM-friendly version is generated for each page
- 📝 Generates
llms.txtwith section links - 📖 Generates
llms-full.txtwith all content in one file
📖 llmstxt.org Standard
This plugin follows the llmstxt.org standard, which defines the best practices for LLM-friendly documentation.
✨ Projects where this plugin is used
❤️ Support
If you like this project, consider supporting it by starring ⭐ it on GitHub, sharing it with your friends, or buying me a coffee ☕
🤝 Contributing
You can read the instructions for contributing here - CONTRIBUTING.md
📜 License
MIT License © 2025-present Yurii Bogdan
👨🏭 Contributors
Thank you to everyone who helped with the project!
Fuente: GitHub
