Generate or update the site's /llms.txt endpoint. Run this after adding, removing, or significantly editing content.
Overview
The /llms.txt file follows the llmstxt.org specification — a Markdown file at the site root that helps LLMs understand the site's content and structure.
Step 1 — Read site context
Read these files to understand the current site state:
- •
src/config.ts— author info, site URL, social links, navigation - •
src/pages.config.ts— page descriptions and headings - •
src/content.config.ts— content collection schemas
Step 2 — Read all content collections
Read all non-draft MDX files from each collection to gather titles, summaries, and metadata:
- •
src/content/projects/*.mdx— extracttitle,role,year,outcomeSummary,status - •
src/content/publications/*.mdx— extracttitle,authors,journal,publishDate - •
src/content/journey/*.mdx— extractdate,title,type,description - •
src/content/tools/*.mdx— extractname,description,is_favorite
Filter out any entries with draft: true.
Step 3 — Generate llms.txt content
Follow the llmstxt.org specification exactly:
# {Site Title}
> {Brief summary of the site and its author — 2-3 sentences from config and pages.config}
{A short paragraph about the site's purpose, structure, and content types}
## Projects
- [{title}]({url}): {outcomeSummary}
(repeat for each non-draft project, sorted by year descending)
## Publications
- [{title}]({url}): {journal}, {publishDate year}. Authors: {authors joined}
(repeat for each non-draft publication, sorted by publishDate descending)
## Journey
- [{title}]({url}): {description} ({date year})
(repeat for each non-draft journey entry, sorted by date descending)
## Tools
- [{name}]({url}): {description}
(repeat for each non-draft tool, sorted by is_favorite descending then name)
## Optional
- [Sitemap]({siteUrl}/sitemap-index.xml): XML sitemap for all pages
URL format
- •Projects:
{siteUrl}/projects/{slug}/ - •Publications:
{siteUrl}/publications/(publications are listed on a single paginated page, no individual routes) - •Journey:
{siteUrl}/journey/(journey is a single timeline page, no individual routes) - •Tools:
{siteUrl}/tools/(tools are listed on a single page, no individual routes)
For collections without individual pages (publications, journey, tools), link to the listing page instead of per-item URLs.
Slug derivation
Project slugs are derived from the MDX filename (without .mdx extension).
Step 4 — Write the endpoint
The file should be an Astro API route at src/pages/llms.txt.ts, following the same pattern as src/pages/robots.txt.ts:
- •Import content collections using
getCollectionfromastro:content - •Filter out drafts
- •Sort entries as specified above
- •Build the Markdown string
- •Return a
ResponsewithContent-Type: text/plain; charset=utf-8
If the file already exists, update it. If not, create it.
Step 5 — Validate
- •Run
bun run buildto verify the route compiles - •Check that
dist/llms.txtexists in the build output and contains the expected content