This is the abridged developer documentation for starlight-llms-txt
# Configuration
> How to customize the llms.txt and llms-full.txt files generated by the starlight-llms-txt plugin
The `starlight-llms-txt` plugin can be configured in your Astro config file: astro.config.mjs
```js
import starlight from '@astrojs/starlight';
import { defineConfig } from 'astro/config';
import starlightLlmsTxt from 'starlight-llms-txt';
export default defineConfig({
site: 'https://example.com/',
integrations: [
starlight({
title: 'My Docs',
plugins: [
starlightLlmsTxt({
projectName: 'Very Cool Tool',
}),
],
}),
],
});
```
## Options [Section titled “Options”](#options) The following configuration options are available to pass to the plugin: ### `projectName` [Section titled “projectName”](#projectname) **Type:** `string`\ **Default:** the value of Starlight’s `title` option Provide a custom name for this project or software. This will be used in `llms.txt` to identify what the documentation is for. For example, with `projectName: "FastHTML"`, the generated `llms.txt` file would start: llms.txt
```md
# FastHTML
## Documentation Sets
- [Complete documentation](https://example.com/llms-full.txt): the full documentation for FastHTML
```
### `description` [Section titled “description”](#description) **Type:** `string`\ **Default:** the value of Starlight’s `description` option Set a custom description for your documentation site to share with large language models. Can include Markdown syntax. Will be displayed as a blockquote in `llms.txt` immediately after the file’s title. According to [llmstxt.org](https://llmstxt.org/) this should be: > a short summary of the project, containing key information necessary for understanding the rest of the file ### `details` [Section titled “details”](#details) **Type:** `string`\ **Default:** `undefined` Provide additional details to add after the `description` in `llms.txt`. According to [llmstxt.org](https://llmstxt.org/) this should be: > Zero or more markdown sections (e.g. paragraphs, lists, etc) of any type except headings, containing more detailed information about the project and how to interpret the provided files ### `optionalLinks` [Section titled “optionalLinks”](#optionallinks) **Type:** `Array<{ label: string; url: string; description?: string }>`\ **Default:** `[]` An array of optional links to add to the `llms.txt` entrypoint. URLs provided here can be skipped by the LLM if a shorter context is needed. Use it for secondary information which is not already in your docs content. ### `customSets` [Section titled “customSets”](#customsets) **Type:** `Array<{ label: string; paths: string[]; description?: string; }>`\ **Default:** `[]` Specify additional subsets of your docs pages to generate and link to from `llms.txt`. This can be helpful for large docs sites where you need to break up your content into categories, so that LLMs can choose what data to ingest. Each custom set should define a label and an array of page slugs or glob patterns that match page slugs to include. Glob patterns are processed using [`micromatch`’s matching features](https://github.com/micromatch/micromatch#matching-features).
```js
customSets: [
{
label: 'Reference',
description: 'full reference documentation for my project',
paths: ['reference/**'],
},
{
label: 'Tutorial',
description: 'step-by-step tutorial for how to build a new project',
paths: ['tutorial/**'],
},
];
```
### `promote` [Section titled “promote”](#promote) **Type:** `string[]`\ **Default:** `['index*']` Use the `promote` option to specify pages that should be sorted to the top of the `llms-full.txt` and `llms-small.txt` files. The value should be an array of page slugs or glob patterns that match page slugs. Glob patterns are processed using [`micromatch`’s matching features](https://github.com/micromatch/micromatch#matching-features). The default value promotes the index page. If you’d like to promote more or other pages, add them to the array:
```ts
// Example: In addition to the index page, also promote `getting-started`
// and any pages in the root directory to the top of the output
promote: ['index*', 'getting-started*', '!*/*'],
```
### `demote` [Section titled “demote”](#demote) **Type:** `string[]`\ **Default:** `[]` Use the `demote` option to specify pages that should be sorted to the bottom of the `llms-full.txt` and `llms-small.txt` files. The value should be an array of page slugs or glob patterns that match page slugs. Glob patterns are processed using [`micromatch`’s matching features](https://github.com/micromatch/micromatch#matching-features). If a page matches patterns in both `promote` and `demote`, it will be demoted. ### `exclude` [Section titled “exclude”](#exclude) **Type:** `string[]`\ **Default:** `[]` Use the `exclude` option to specify docs pages that should be excluded when generating `llms-small.txt`. This allows you to filter out non-essential documentation for models with a smaller context window. The value of `exclude` is an array of page slugs or glob patterns that match page slugs. Glob patterns are processed using [`micromatch`’s matching features](https://github.com/micromatch/micromatch#matching-features). In the following example, a specific, outdated page is excluded as well as all pages in the `src/content/docs/tutorial/` directory:
```ts
exclude: ['old-page', 'tutorial/**'],
```
### `rawContent` [Section titled “rawContent”](#rawcontent) **Type:** `boolean`\ **Default:** `false` When enabled, returns raw Markdown content without processing. Useful for large documentation sites where processing time is a concern. You must enable the `rawContent` option if your content includes components built with UI frameworks like React, Vue, Svelte, etc.
```ts
rawContent: true,
```
### `customSelectors` [Section titled “customSelectors”](#customselectors) **Type:** `string[] | { small?: string[]; full?: string[]; all?: string[] }`\ **Default:** `[]` CSS-style selectors matching elements that should be removed from the rendered HTML before it is converted to Markdown. Selectors are tested with [`hast-util-select`’s matching features](https://github.com/syntax-tree/hast-util-select#support) and should match your site’s rendered HTML output. Two shapes are supported: * **Array** — selectors apply to `llms-small.txt` only (same scope as the deprecated [`minify.customSelectors`](#minifycustomselectors) option). * **Object** with optional `small`, `full`, and `all` keys, each accepting an array of selectors: * `small` applies to `llms-small.txt`. * `full` applies to `llms-full.txt` and any [`customSets`](#customsets) outputs. * `all` applies to both (merged with `small` and `full`). Selectors listed via the legacy [`minify.customSelectors`](#minifycustomselectors) option are merged additively into the `small` bucket so existing configurations keep working. #### Array form (legacy) [Section titled “Array form (legacy)”](#array-form-legacy)
```ts
customSelectors: ['interactive-demo', '.sponsors-banner'],
```
#### Object form (per-output) [Section titled “Object form (per-output)”](#object-form-per-output) In the following example, hover popovers and error annotations injected by [`expressive-code-twoslash`](https://www.npmjs.com/package/expressive-code-twoslash) are stripped from **every** generated output, leaving the underlying code intact:
```ts
customSelectors: {
all: [
'.twoslash-popup-container',
'.twoslash-static-container',
'.twoslash-completion',
'.twoslash-error-box',
'.twoslash-custom-box',
],
},
```
### `minify` [Section titled “minify”](#minify) A map of content types to filter out of docs when creating `llms-small.txt` for small context windows. Set an element to `true` to filter it out or to `false` to keep it. Use the [`customSelectors`](#minifycustomselectors) option to provide an array of additional CSS-style selectors that match elements to exclude. In the following example, the default exclusion of notes is overridden and a custom in-page navigation component is added to the elements to exclude:
```ts
minify: {
note: false,
customSelectors: ['.my-page-nav'],
},
```
#### `minify.customSelectors` [Section titled “minify.customSelectors”](#minifycustomselectors) **Type:** `string[]`\ **Default:** `[]` Deprecated This option is deprecated. Use the top-level [`customSelectors`](#customselectors) option instead. Selectors listed here continue to apply to `llms-small.txt` only and are merged additively with any selectors in `customSelectors.small` and `customSelectors.all`. Specify custom CSS-style selectors to exclude. Selectors are tested with [`hast-util-select`’s matching features](https://github.com/syntax-tree/hast-util-select#support) and should match your site’s HTML output. In the following example, `customSelectors` is used to exclude an `` custom element and an element showing a project’s sponsors that has the `sponsors-banner` class name:
```ts
customSelectors: ['interactive-demo', '.sponsors-banner'],
```
#### `minify.note` [Section titled “minify.note”](#minifynote) **Type:** `boolean`\ **Default:** `true` Exclude the `note` variant of Starlight’s aside component. #### `minify.tip` [Section titled “minify.tip”](#minifytip) **Type:** `boolean`\ **Default:** `true` Exclude the `tip` variant of Starlight’s aside component. #### `minify.caution` [Section titled “minify.caution”](#minifycaution) **Type:** `boolean`\ **Default:** `false` Exclude the `caution` variant of Starlight’s aside component. #### `minify.danger` [Section titled “minify.danger”](#minifydanger) **Type:** `boolean`\ **Default:** `false` Exclude the `danger` variant of Starlight’s aside component. #### `minify.details` [Section titled “minify.details”](#minifydetails) **Type:** `boolean`\ **Default:** `true` Exclude the `` HTML element. #### `minify.whitespace` [Section titled “minify.whitespace”](#minifywhitespace) **Type:** `boolean`\ **Default:** `true` Collapse whitespace. When `minify.whitespace` is set to `true`, all whitespace — including new lines — is collapsed to a single space character, except inside fenced code blocks. Set [`minify.collapseCodeBlocks`](#minifycollapsecodeblocks) to `true` to collapse whitespace inside fenced code blocks as well. #### `minify.collapseCodeBlocks` [Section titled “minify.collapseCodeBlocks”](#minifycollapsecodeblocks) **Type:** `boolean`\ **Default:** `false` When [`minify.whitespace`](#minifywhitespace) is enabled, also collapse whitespace inside fenced code blocks (` ``` ` and `~~~`). By default, the bodies of fenced code blocks keep their original newlines (and indentation) so multi-line code samples stay multi-line in `llms-small.txt`. Both variable-length fences (e.g. four or more backticks) and tilde fences are recognized. Set this to `true` to collapse every whitespace run — including newlines inside code fences — into a single space:
```js
minify: {
collapseCodeBlocks: true,
},
```
Has no effect when `minify.whitespace` is `false`. ### `pageSeparator` [Section titled “pageSeparator”](#pageseparator) **Type:** `string`\ **Default:** `"\n\n"` The separator used when concatenating page entries together.
```ts
pageSeparator: '\n----------\n',
```
# Getting Started
> How to install and set-up starlight-llms-txt in your Starlight docs site
`starlight-llms-txt` is a plugin for the [Starlight](https://starlight.astro.build/) documentation website framework that auto-generates `llms.txt`, `llms-full.txt`, and `llms-small.txt` context files for large language models based on your documentation site’s content. You can learn more about `llms.txt` files at [llmstxt.org](https://llmstxt.org/). ## Prerequisites [Section titled “Prerequisites”](#prerequisites) You will need to have a Starlight website set up. If you don’t have one yet, you can follow the [“Getting Started”](https://starlight.astro.build/getting-started) guide in the Starlight docs to create one. ## Installation [Section titled “Installation”](#installation) 1. `starlight-llms-txt` is a Starlight [plugin](https://starlight.astro.build/reference/plugins/). Install it by running the following command in your terminal: * npm
```sh
npm i starlight-llms-txt
```
* pnpm
```sh
pnpm add starlight-llms-txt
```
* yarn
```sh
yarn add starlight-llms-txt
```
2. Configure the plugin in your Starlight [configuration](https://starlight.astro.build/reference/configuration/#plugins) in the `astro.config.mjs` file. A `site` URL is also required if you haven’t already set this: astro.config.mjs
```diff
import starlight from '@astrojs/starlight'
import { defineConfig } from 'astro/config'
+import starlightLlmsTxt from 'starlight-llms-txt'
export default defineConfig({
+ site: 'https://example.com/',
integrations: [
starlight({
title: 'My Docs',
+ plugins: [starlightLlmsTxt()],
}),
],
})
```
3. [Start the development server](https://starlight.astro.build/getting-started/#start-the-development-server): * npm
```sh
npm run dev
```
* pnpm
```sh
pnpm run dev
```
* yarn
```sh
yarn run dev
```
4. Visit [`localhost:4321/llms.txt`](http://localhost:4321/llms.txt) to preview the plugin in action. ## Next steps [Section titled “Next steps”](#next-steps) See the [Configuration](https://delucis.github.io/starlight-llms-txt/configuration/) guide to learn how to adjust the output of the plugin.