{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.1.json","id":"generators-llms-txt","path":"/generators/llms-txt","type":"module","module":"generators-llms-txt","title":"llms.txt","introducedIn":null,"sourceLink":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `llms-txt` generator writes an [`llms.txt`](https://llmstxt.org/) file: a\nMarkdown index of your docs that links to each page with a one-line\ndescription, so language models and AI tools can find their way around. Add it\nwhen you publish your docs on the web.\n\nTo hand models the Markdown of every page in one file as well, add\n[llms-full.txt](https://doc-kit.nodejs.org/generators/llms-txt-full)\n(`llms-txt-full`).","summary":"The `llms-txt` generator writes an `llms.txt` file: a Markdown index of your docs that links to each page with a one-line description, so language models and AI tools can find their way around. Add it when you publish your docs on the web.","examples":[],"children":[{"kind":"section","id":"usage","name":"Usage","title":"Usage","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The links in `llms.txt` are absolute URLs, so set `baseURL` to where your docs\nare published. There is no flag for it, so set it in your configuration file.\n\n```bash\nnpx @doc-kit/cli generate -t llms-txt -i \"docs/**/*.md\" -o out\n```\n\nFor a project named `my-lib` with `docs/index.md` and `docs/guide/usage.md`,\nthis writes:\n\n```text displayName=\"out/llms.txt\"\n# my-lib Documentation\n\n> API documentation for my-lib.\n\nBelow are the sections of the API documentation. Look out especially towards the links that point towards guidance/introduction to the structure of this documentation.\n\n## API Documentations\n- [Usage](https://example.com/guide/usage.md): How to call my-lib from your code.\n- [My library](https://example.com/index.md): A small library for working with strings.\n```","summary":"The links in `llms.txt` are absolute URLs, so set `baseURL` to where your docs are published. There is no flag for it, so set it in your configuration file.","examples":[{"language":"bash","displayName":null,"code":"npx @doc-kit/cli generate -t llms-txt -i \"docs/**/*.md\" -o out"},{"language":"text","displayName":"out/llms.txt","code":"# my-lib Documentation\n\n> API documentation for my-lib.\n\nBelow are the sections of the API documentation. Look out especially towards the links that point towards guidance/introduction to the structure of this documentation.\n\n## API Documentations\n- [Usage](https://example.com/guide/usage.md): How to call my-lib from your code.\n- [My library](https://example.com/index.md): A small library for working with strings."}],"children":[]},{"kind":"section","id":"configuring","name":"Configuring","title":"Configuring","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"* `templatePath` {string} The text file `llms.txt` starts with (see\n  [The template](#the-template)). A relative path resolves against the\n  directory you run doc-kit from. **Default:** the bundled `template.txt`.\n* `pageURL` {string} URL template for each page's link. `{path}` is the page's\n  path, without its extension and starting with a slash; see\n  [templates](https://doc-kit.nodejs.org/configuration#generator-options).\n  **Default:** `'{baseURL}{path}.md'`.\n\nIt also reads the\n[global options](https://doc-kit.nodejs.org/configuration#global-options).","summary":"It also reads the global options.","examples":[],"children":[]},{"kind":"section","id":"what-it-lists","name":"What it lists","title":"What it lists","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"`llms.txt` has one line for each top-level (`#`) heading in your sources, as\n`- [Heading](URL): Description`:\n\n* **Heading** is the heading's text. A page without a `#` heading isn't listed,\n  and a page with several gets a line for each.\n* **URL** is `pageURL` filled in for the page. `{path}` is the source file's\n  path relative to the base of the input glob: with `-i \"docs/**/*.md\"`,\n  `docs/guide/usage.md` becomes `/guide/usage`.\n* **Description** is the page's `llm_description` when it has one. Otherwise\n  it's the first paragraph between the heading and the next heading, on one\n  line: inline code, bold and italics keep their Markdown, and links become\n  plain text. Without such a paragraph, it's empty.\n\nIf your opening paragraph doesn't make a good summary on its own, write one for\nmodels with the\n[`llm_description` directive](https://doc-kit.nodejs.org/specification#624-llm_description),\nright after the heading it describes:\n\n```markdown displayName=\"docs/guide/usage.md\"\n# Usage\n\n<!-- llm_description=How to call my-lib from your code. -->\n```\n\n[Section pages](https://doc-kit.nodejs.org/generators/section-pages) aren't\nlisted: `llms.txt` links to the full pages.","summary":"`llms.txt` has one line for each top-level (`#`) heading in your sources, as `- [Heading](URL): Description`:","examples":[{"language":"markdown","displayName":"docs/guide/usage.md","code":"# Usage\n\n<!-- llm_description=How to call my-lib from your code. -->"}],"children":[]},{"kind":"section","id":"the-template","name":"The template","title":"The template","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"`llms.txt` is the template's text followed directly by the list of links, so\nend the template with a newline. This is the default:\n\n```text displayName=\"template.txt\"\n# {project} Documentation\n\n> API documentation for {project}.\n\nBelow are the sections of the API documentation. Look out especially towards the links that point towards guidance/introduction to the structure of this documentation.\n\n## API Documentations\n```\n\nThe format at [llmstxt.org](https://llmstxt.org/) expects a `#` title with\nyour project's name, then a `>` summary, then `##` sections of links. A\ntemplate of your own can describe your project better and add links of its own\nabove the generated list.\n\nPlaceholders such as `{project}` take configuration values; see\n[templates](https://doc-kit.nodejs.org/configuration#generator-options).","summary":"`llms.txt` is the template's text followed directly by the list of links, so end the template with a newline. This is the default:","examples":[{"language":"text","displayName":"template.txt","code":"# {project} Documentation\n\n> API documentation for {project}.\n\nBelow are the sections of the API documentation. Look out especially towards the links that point towards guidance/introduction to the structure of this documentation.\n\n## API Documentations"}],"children":[]},{"kind":"section","id":"serving-pages-as-markdown","name":"Serving pages as Markdown","title":"Serving pages as Markdown","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The default `pageURL` links to a `.md` file at each page's path\n(`/guide/usage.md` next to `/guide/usage.html`), as llmstxt.org proposes,\nsince Markdown is easier for language models to read than HTML. doc-kit\ndoesn't write those files, so copy your sources into the output. With the\n[website](https://doc-kit.nodejs.org/generators/html), its `pathsToCopy` option\ndoes it:\n\n```js displayName=\"doc-kit.config.mjs\"\nexport default {\n  target: ['html', 'llms-txt'],\n  global: {\n    input: ['docs/**/*.md'],\n    output: 'out',\n    baseURL: 'https://example.com',\n  },\n  html: {\n    // Copies the contents of docs/ into out/\n    pathsToCopy: ['public', { docs: '.' }],\n  },\n};\n```\n\nSetting `pathsToCopy` replaces its default list (`assets`, `public` and\n`static`), so keep the ones you use, as `public` is kept here. doc-kit's own\nsite builds its [`llms.txt`](https://doc-kit.nodejs.org/llms.txt) this way.\nIf you don't serve Markdown, link to the HTML pages instead with\n`pageURL: '{baseURL}{path}.html'`.","summary":"The default `pageURL` links to a `.md` file at each page's path (`/guide/usage.md` next to `/guide/usage.html`), as llmstxt.org proposes, since Markdown is easier for language models to read than HTML. doc-kit doesn't write those files, so copy your sources into the output. With the website, its `pathsToCopy` option does it:","examples":[{"language":"js","displayName":"doc-kit.config.mjs","code":"export default {\n  target: ['html', 'llms-txt'],\n  global: {\n    input: ['docs/**/*.md'],\n    output: 'out',\n    baseURL: 'https://example.com',\n  },\n  html: {\n    // Copies the contents of docs/ into out/\n    pathsToCopy: ['public', { docs: '.' }],\n  },\n};"}],"children":[]}]}