Sub topic 6
Writing an `llms.txt` File
This chapter assumes that you understand how a website is served over HTTP, can read basic Markdown, and know that AI assistants may retrieve web pages. You should also know that llms.txt is a proposed convention, not an access-control mechanism. A crawler can ignore it.
Start with the file structure
Place the file at the site root:
https://example.com/llms.txtUse plain text encoded as Markdown. A typical file contains:
- One H1 heading naming the site or product.
- A short summary of the site's purpose.
- H2 sections that group related documentation.
- Markdown links with short descriptions.
- An
Optionalsection for material that is useful but less important.
Keep the file focused on pages that help an assistant understand or use your product. Link to documentation, guides, API references, tutorials, policies, and other authoritative pages.
# Example Docs
Documentation for the Example library, a Python client for the Example API.
## Docs
- [Quickstart](https://example.com/docs/quickstart.md): Install the library and make a first request
- [API reference](https://example.com/docs/api.md): Endpoints, parameters, and error codes
## Guides
- [Authentication](https://example.com/docs/auth.md): Configure API keys and service accounts
- [Webhooks](https://example.com/docs/webhooks.md): Receive event notifications
## Optional
- [Changelog](https://example.com/changelog.md): Release historyThe H1 identifies the collection. The introductory text gives a compact description. Each link has a destination and a description that explains when the page is useful.
Choose and order links
Put the most important material first. A useful order is:
- A quickstart or overview.
- Core concepts.
- Task-based guides.
- API or reference documentation.
- Troubleshooting and policy pages.
- Optional background material.
Use stable, canonical URLs. Avoid links that require a login unless the intended consumers can authenticate. Do not list every page automatically. A long list of duplicate, obsolete, or low-value pages makes the file less useful.
Descriptions should add context rather than repeat the page title. For example, “Configure API keys and service accounts” tells a reader more than “Authentication documentation.”
Review the result
Before publishing, check that:
- The file is available at
/llms.txt. - It returns a successful HTTP response.
- Links use the correct canonical host and paths.
- Descriptions match the linked pages.
- Important pages appear before optional pages.
- No secret, private, or unpublished URL is included.
The file can help a consumer discover relevant content, but it does not force a crawler to read those pages. It also does not guarantee better rankings, citations, or visibility in an AI assistant.
Test the published file
You can inspect the response with a command such as:
curl -i https://example.com/llms.txtConfirm that the response contains the expected Markdown and that the server does not redirect to an unintended host. Then test several links from the file. A valid index is useful only when its destinations are reachable and current.
Exercise
Should you list every URL on your site in llms.txt?
Show answer
No. Curate the most authoritative and useful pages, put essential content first, and place less important material in an Optional section.