Most agent traffic to a content site still arrives as an HTML crawl. That works, but it is wasteful: the agent downloads navigation, cookie banners, inline scripts, and tracking tags, then throws most of it away before it can read the article.

llms.txt helps an agent find the right page. It does not help it read that page cheaply. So we added a second representation: every prerendered page gets a Markdown twin, and the edge negotiates between HTML and Markdown with a normal Accept header.

This is how it works on a production Astro site running on Cloudflare Workers, including the parts that broke on the first attempt.

The shape of the idea

For every page /roofing-answering-service/ there is also /roofing-answering-service.md. The HTML page advertises the twin with a Link: rel="alternate" header. An agent that asks for Accept: text/markdown gets the twin directly. A human browser asking for HTML gets the page it always got.

Two rules keep this honest:

  1. Markdown is generated from the built HTML, never hand-written. If the page changes, the twin changes in the same build.
  2. The twin is a representation of the same URL, not a new URL. Canonical stays on the HTML page.

Generating the twins at build time

The build runs after astro build and walks the prerendered output. For each index.html it converts the rendered document to Markdown and writes a sibling .md file. It also builds llms.txt as a curated index and llms-full.txt as one long document.

The important detail is the source: it reads dist/client, not the Astro components. That means the Markdown reflects what a visitor actually sees, including content that comes from data files. Extracting from source templates is where drift starts.

A trimmed version of the pipeline:

const pages = await collectPages(CLIENT_DIR); // [{ url, htmlPath }] for (const page of pages) { const html = await readFile(page.htmlPath, 'utf8'); const markdown = htmlToMarkdown(html, { baseUrl: SITE + page.url }); await writeFile(toMarkdownPath(page.htmlPath), markdown, 'utf8'); } await writeFile(path.join(CLIENT_DIR, 'llms.txt'), renderLlmsTxt(pages), 'utf8'); 

llms.txt gets a short section list, not a sitemap dump. Agents do better with ten labelled groups than with five hundred unlabelled URLs.

Negotiating at the edge

Astro's Cloudflare adapter serves static assets through the worker. If the worker does not run first, Accept never reaches your code and the static HTML wins. The generated wrangler config sets run_worker_first, and the gateway handles the request before assets.

The negotiation itself is small:

function chooseRepresentation(accept) { const html = quality(accept, 'text/html'); const md = quality(accept, 'text/markdown'); if (md === 0 && html === 0 && accept.trim() && accept !== '*/*') return 'not-acceptable'; return md > html ? 'markdown' : 'html'; } 

quality() parses q-values, so Accept: text/html;q=0.9, text/markdown;q=0.8 returns HTML, and text/markdown alone returns Markdown. The fallback matters: if a client explicitly rejects both representations, answer 406 with a Link header pointing at both, instead of silently serving HTML it said it did not want.

Two headers go on every response:

Vary: Accept Link: <https://example.com/page.md>; rel="alternate"; type="text/markdown" 

Vary is not optional. Without it a CDN can cache the Markdown response and hand it to a browser, or the reverse.

What broke

Trailing slashes. /page and /page/ are different cache keys. Both must map to the same .md file, and both should redirect to one canonical form before negotiation.

File extensions. A request for /og.png must not be treated as a page. Anything with a real extension goes straight to assets.

Missing twins. If a page has no twin, return HTML rather than a 404. A partial rollout should degrade, not break.

Double conversion. Converting Markdown back to HTML for browsers is tempting and always wrong. Keep one source of truth and convert in one direction.

Does it help rankings?

No. Search Console does not care. This is about the other half of discovery: agents that read your site to answer a question and cite a source.

What it changes is cost and fidelity. An agent fetches a 40 KB Markdown file instead of a 300 KB HTML document with the same words buried in markup. Fewer tokens, cleaner text, fewer chances to misread a table as navigation.

If you also enable Cloudflare's newer Search for Agents toggle, the zone gets a /.well-known/search endpoint and the pages advertise it with agent:endpoint meta tags. The two layers are complementary: Markdown for reading one page, search for finding the right page.

Checking it yourself

curl -sI https://inqari.com/roofing-answering-service/ | grep -i '^link\|^vary' curl -s -H 'Accept: text/markdown' https://inqari.com/roofing-answering-service/ | head -5 curl -s https://inqari.com/llms.txt | head -20 

Live examples from the site this was built for:

The whole layer is a few hundred lines of build script plus a request handler. The hard part is not the code, it is resisting the urge to maintain two copies of the content.