🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
SEO••By Komal Nakrani

Astro llms.txt: Make Your Site Citable by AI Search

Add an Astro llms.txt endpoint generated from your content collections, serve Markdown copies of pages, allow AI crawlers, and write pages AI answers can cite.

#Astro#llms.txt#AI Search#SEO#Content Collections

To add an Astro llms.txt file, create a static endpoint at src/pages/llms.txt.ts that lists your key pages as Markdown links with one-line summaries, generated from your content collections at build time. That gives AI tools a compact map of the site. On its own it won’t get you cited; that also takes crawlable HTML, AI crawlers allowed in robots.txt, and pages that answer questions directly.

This guide covers the file itself, the optional Markdown copies that go with it, and the page-level habits that matter more than either.

Key Takeaways

  • llms.txt is a proposed standard (llmstxt.org): a Markdown file at /llms.txt with a title, a summary and lists of links to your most useful pages.
  • Generate it from getCollection() so it never goes stale. Astro writes it to dist/llms.txt as a static file.
  • Support from AI companies is uneven, and Google has said its Search doesn’t use it. Treat it as cheap and optional.
  • What reliably helps: server-rendered HTML (Astro’s default), AI crawlers allowed in robots.txt, direct answers at the top of pages, structured data, and clear authorship and dates.
  • Measure with referral traffic from AI assistants and crawler hits in your host’s logs.

What llms.txt is

llms.txt was proposed in September 2024 by Jeremy Howard of Answer. AI. The idea: HTML pages are full of navigation, scripts and layout that a language model has to wade through. A single Markdown file at the root of the site can point a model straight at the content that matters, with a sentence on each.

The format, from the llms.txt specification:

  1. An H1 with the site or project name (required).
  2. A blockquote with a short summary.
  3. Optional paragraphs with more context.
  4. H2 sections, each with a Markdown list of links, optionally followed by a colon and a description.
  5. An optional section titled “Optional” for links that can be skipped when context is short.

A companion convention is /llms-full.txt, one file containing the full text of the key pages, and .md versions of individual pages at the same URL plus .md.

Is llms.txt worth adding?

Be realistic about it. llms.txt is a proposal, not a web standard, and the large AI search products haven’t committed to reading it. Google’s Search team has said publicly that Google Search doesn’t use it. Some AI coding tools and agents do fetch it, especially for developer documentation, which is where adoption is strongest.

On an Astro site the cost is one endpoint file that regenerates itself on every build. That’s cheap enough to add for docs, guides and product catalogs, as long as you don’t expect it to move traffic on its own. Spend most of your effort on the page-level work further down.

Generate llms.txt from content collections

// src/pages/llms.txt.ts
import type { APIRoute } from 'astro';
import { getCollection } from 'astro:content';

export const GET: APIRoute = async ({ site }) => {
  const base = site!.href.replace(/\/$/, '');
  const posts = (await getCollection('blog', ({ data }) => !data.draft))
    .sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
  const docs = await getCollection('docs');

  const lines = [
    '# Example Studio',
    '',
    '> Example Studio builds fast marketing sites with Astro. This site has guides on Astro, deployment and SEO, plus documentation for our starter kits.',
    '',
    '## Docs',
    ...docs.map((d) => `- [${d.data.title}](${base}/docs/${d.id}/): ${d.data.description}`),
    '',
    '## Guides',
    ...posts.slice(0, 50).map((p) => `- [${p.data.title}](${base}/blog/${p.id}/): ${p.data.description}`),
    '',
    '## Optional',
    `- [All blog posts](${base}/blog/): full archive`,
    `- [About](${base}/about/): who runs the site`,
  ];

  return new Response(lines.join('\n'), {
    headers: { 'Content-Type': 'text/plain; charset=utf-8' },
  });
};

Build the site and check dist/llms.txt. Because this endpoint has no dynamic parameters, Astro prerenders it once and writes a plain file, so it works on any static host.

Notes:

  • Use description from frontmatter. If your schema requires it, every link gets a summary automatically. That’s the same text you wrote for search snippets, which is usually exactly the right length.
  • Pick, don’t dump. The point is to highlight the best pages. Fifty recent guides plus your docs is plenty; the archive link covers the rest.
  • Absolute URLs. Build them from site so the file works when fetched on its own.

Serve Markdown copies of pages

Models read Markdown more cheaply than HTML. You can expose the raw Markdown body of each post at a parallel URL with a static endpoint:

// src/pages/blog/[id].md.ts
import type { APIRoute, GetStaticPaths } from 'astro';
import { getCollection, type CollectionEntry } from 'astro:content';

export const getStaticPaths = (async () => {
  const posts = await getCollection('blog', ({ data }) => !data.draft);
  return posts.map((post) => ({ params: { id: post.id }, props: { post } }));
}) satisfies GetStaticPaths;

export const GET: APIRoute = ({ props }) => {
  const { post } = props as { post: CollectionEntry<'blog'> };
  const body = `# ${post.data.title}\n\n${post.data.description}\n\n${post.body ?? ''}`;
  return new Response(body, {
    headers: { 'Content-Type': 'text/markdown; charset=utf-8' },
  });
};

This writes dist/blog/my-post.md next to dist/blog/my-post/index.html. Two caveats: MDX files contain import lines and component tags that read as noise, so strip or skip them; and these copies shouldn’t compete with your HTML in search. Keep them out of the sitemap, and send X-Robots-Tag: noindex for *.md in your host’s headers file:

# public/_headers (Cloudflare Pages and Netlify)
/blog/*.md
  X-Robots-Tag: noindex

An llms-full.txt is the same idea concatenated: one endpoint that joins every post body into one file. Only add it if the total stays small enough to be useful as a single document.

Let AI crawlers in

None of this matters if your robots.txt blocks the bots. AI companies use separate user agents for training and for live search or retrieval, and you can allow or block each:

User agent Operator Purpose
OAI-SearchBot OpenAI Search results in ChatGPT
ChatGPT-User OpenAI Fetches pages a user asks about
GPTBot OpenAI Model training
Claude-SearchBot Anthropic Search for Claude
Claude-User Anthropic Fetches pages a user asks about
ClaudeBot Anthropic Model training
PerplexityBot Perplexity Search index
Google-Extended Google Control token for Gemini training, not a separate crawler

A policy that allows search and user-initiated fetches but opts out of training looks like this:

# public/robots.txt
User-agent: *
Allow: /

User-agent: GPTBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: Google-Extended
Disallow: /

Sitemap: https://www.example.com/sitemap-index.xml

Whether to opt out of training is a business decision. If your goal is to be cited, the search and user agents must be allowed. Also check your CDN: some hosts offer one-click AI bot blocking that overrides robots.txt. The Astro robots.txt tip shows how to generate the file dynamically.

Write pages AI answers can quote

AI search tools retrieve a handful of pages for a question and quote the passages that answer it best. The page-level habits that make that likely are the same ones that win featured snippets:

  1. Answer first. Put a one-to-three sentence direct answer at the top, containing the question’s key terms. That’s the passage most likely to be quoted.
  2. One question per section. Clear H2s phrased the way people ask (“How do I add a sitemap to Astro?”) make sections easy to match to queries.
  3. Concrete facts. Version numbers, file paths, commands and dates are quotable. Vague claims aren’t.
  4. Visible authorship and dates. A named author and a “last updated” date help a model judge whether the source is current.
  5. An FAQ section with real questions and short answers. The FAQ section component renders one with matching schema.

Astro helps with the technical side by default: pages are server-rendered HTML, so the content is in the first response for crawlers that don’t run JavaScript, which most AI crawlers don’t.

Add structured data

JSON-LD gives a machine-readable statement of what the page is, who wrote it and when it was updated. BlogPosting or TechArticle with author, datePublished and dateModified, plus a site-wide Organization, covers most sites. The Astro JSON-LD guide has the components.

Measure whether it’s working

There’s no AI equivalent of Search Console yet, so combine signals:

  • Referral traffic. In your analytics, look for referrers such as chatgpt.com, perplexity.ai, claude.ai, gemini.google.com and copilot.microsoft.com. Many AI tools now add a referrer or utm_source when users click a citation.
  • Crawler hits. Your host’s analytics or logs show requests by user agent. Hits from OAI-SearchBot, Claude-SearchBot or PerplexityBot on a page mean it’s in their index.
  • Manual checks. Ask the assistants your target questions every few weeks and note which sources they cite. Keep a simple spreadsheet; it’s slow, but it’s the only direct measure.

Crawler hits on /llms.txt specifically tell you whether anything reads it. If nothing does after a few months, that’s useful information too.

A checklist for AI citability on Astro

  1. Server-rendered or prerendered HTML for all content pages (the Astro default).
  2. robots.txt allows the search and user-fetch agents you care about.
  3. A sitemap, linked from robots.txt.
  4. Direct answers in the first paragraph of every guide.
  5. JSON-LD with author and dates.
  6. An llms.txt endpoint generated from your collections.
  7. Optional .md copies with noindex headers.
  8. Referral and crawler monitoring.

The rest of the technical groundwork is in the Astro SEO checklist, and the content collections docs explain how theme content is organized for endpoints like these. Every Komal theme builds to static HTML, so all of the above can be added to one without changing how it deploys; you can browse Astro themes to see the page structures they start with.

FAQ

What is llms.txt?

llms.txt is a proposed convention for a Markdown file at /llms.txt that summarizes a website and links to its most useful pages, so language models can find the important content without parsing every HTML page. It was proposed in September 2024 and is published at llmstxt.org.

Does Google use llms.txt?

Google’s Search team has said Google Search doesn’t use llms.txt. Some AI tools and agents fetch it, mainly for developer documentation, so support depends on the product.

How do I add llms.txt to an Astro site?

Create src/pages/llms.txt.ts with a GET function that builds the Markdown from getCollection() and returns it as text/plain. Astro prerenders it to dist/llms.txt at build time. A static file in public/llms.txt also works if you’d rather maintain it by hand.

Should I block AI crawlers in robots.txt?

Block training crawlers such as GPTBot or ClaudeBot if you don’t want your content used for model training. If you want to be cited in AI answers, allow the search and user-initiated agents such as OAI-SearchBot, ChatGPT-User, Claude-SearchBot and PerplexityBot.

How do I know if ChatGPT or Perplexity cites my site?

Check analytics for referrals from chatgpt.com and perplexity.ai, look for their crawlers in your host’s request logs, and periodically ask the assistants your target questions to see which sources they list.