Skip to content

Use Markdown for Agents for all docs markdown generation#28921

Merged
mvvmm merged 20 commits intoproductionfrom
use-md-for-agents-for-all-md
Mar 16, 2026
Merged

Use Markdown for Agents for all docs markdown generation#28921
mvvmm merged 20 commits intoproductionfrom
use-md-for-agents-for-all-md

Conversation

@mvvmm
Copy link
Contributor

@mvvmm mvvmm commented Mar 11, 2026

Summary

This PR replaces the custom rehype-based HTML-to-Markdown pipeline with Cloudflare's Markdown for Agents (MFA) network-layer feature, which converts any HTML page to Markdown when requested with an Accept: text/markdown header.

The /path/index.md URL pattern is preserved for backwards compatibility. Requests to /path/index.md are handled by a Cloudflare Transform Rule that rewrites the URL to /path/ and a Request Header Transform Rule that adds Accept: text/markdown — triggering MFA to return Markdown instead of HTML.

What changed

Removed the custom Markdown pipeline:

  • Deleted src/util/markdown.ts — the custom htmlToMarkdown() function and rehype pipeline
  • Deleted src/content/docs/style-guide/fixtures/ — test fixture pages used by the old pipeline
  • Removed the index.md handler from worker/index.ts and src/middleware/index.ts
  • Removed associated Worker tests

Updated documentation:

  • src/content/docs/style-guide/how-we-docs/ai-consumability.mdx — updated the "Turning our components into Markdownable HTML" section to describe MFA instead of the rehype plugin
  • src/content/partials/style-guide/llms-txt.mdx — updated to reflect MFA as the underlying mechanism, with Accept: text/markdown as the primary recommendation

Updated llms.txt generation:

  • Replaced src/pages/[product]/llms.txt.ts with src/pages/[...product]/llms.txt.ts — a catch-all route that derives each product's llms.txt URL from entry.data.entry.url instead of the YAML filename (entry.id). This fixes broken and mismatched llms.txt URLs for products whose canonical URL path differs from their entry ID (e.g. cloudflare-for-saas/cloudflare-for-platforms/cloudflare-for-saas/llms.txt).
  • Root llms.txt now links to each product using its canonical URL (entry.data.entry.url) rather than /${entry.id}/, fixing the same class of broken links.
  • Root llms.txt no longer lists sub-products that are fully covered by their parent's llms.txt (e.g. Cache Rules, Logpush, Access), eliminating ~58 duplicate entries and preventing the same pages from appearing twice when enumerating from root. Sub-product llms.txt files still exist at their canonical URLs.
  • Root llms.txt adds a new ## Other section listing ungrouped directory entries (e.g. style-guide, security, use-cases) that have docs pages but no product group.
  • Per-product llms.txt files group pages into sections using sidebar.order from each section's index.mdx frontmatter, matching the visible sidebar structure. Products without sidebar ordering fall back to a flat list.
  • Page links in per-product llms.txt files now point directly to index.md URLs (e.g. /workers/get-started/guide/index.md) so agents and parsers receive Markdown immediately without needing to set headers or rewrite URLs.
  • Sidebar links to llms.txt and llms-full.txt in the Developer Platform section are updated to use canonical URL paths.
  • The per-product blockquote is simplified — since links already point to Markdown, the two-method explanation is removed and replaced with a single note that links are Markdown, plus the llms-full.txt pointer.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

This PR requires additional review attention because it affects the following areas:

Redirects

This PR changes current filenames or deletes current files. Make sure you have redirects set up to cover the following paths:

  • /style-guide/fixtures/
  • /style-guide/fixtures/markdown/

Partials

This PR updates partial files, which are pieces of content used across multiple files in our Render component.

@github-actions
Copy link
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
*.ts @cloudflare/content-engineering, @kodster28
/src/content/docs/style-guide/ @dcpena, @cloudflare/pcx-technical-writing
* @cloudflare/pcx-technical-writing

@mvvmm mvvmm marked this pull request as ready for review March 12, 2026 21:46
@mvvmm mvvmm requested review from a team, dcpena and kodster28 as code owners March 12, 2026 21:46
@mvvmm
Copy link
Contributor Author

mvvmm commented Mar 13, 2026

/bonk please review this PR for any regressions or issues

Copy link
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted 3 inline suggestions and 2 notes below.

@ask-bonk
Copy link
Contributor

ask-bonk bot commented Mar 13, 2026

MEDIUM — Missing redirects for deleted fixture pages.

The bot flagged this too: src/content/docs/style-guide/fixtures/index.mdx and src/content/docs/style-guide/fixtures/markdown.mdx were deleted but no redirects were added to public/__redirects. These pages were hidden (sidebar.hidden: true) and marked noindex, so external traffic is unlikely — but any existing bookmarks or CI references to /style-guide/fixtures/ or /style-guide/fixtures/markdown/ will 404. Add redirects to /style-guide/ if you want to be safe, or acknowledge these can 404.

@ask-bonk
Copy link
Contributor

ask-bonk bot commented Mar 13, 2026

Review posted on PR #28921. Here's a summary of what I flagged:

MEDIUM (1 item):

  • Missing redirects for deleted /style-guide/fixtures/ and /style-guide/fixtures/markdown/ pages. No entry in public/__redirects. Low-traffic risk since pages were hidden and noindexed, but worth adding.

LOW (4 items):

  • ai-consumability.mdx line 44 — "MFA" acronym introduced but barely reused, and collides with "multi-factor authentication" in Cloudflare's product space. Suggested dropping the abbreviation.
  • ai-consumability.mdx lines 79-80 — The turndown baseline row was removed from the token comparison table. Fine to simplify, but flagged the decision since the intermediate data point provided useful context.
  • [product]/llms.txt.ts line 134 — Inconsistent spacing between flat fallback (\n) and sections branch (\n\n) for the root link separator.
  • worker/index.worker.test.ts line 185 — The test for the rel='alternate' index.md link tag was removed, but the tag is still emitted from Head.astro line 232. Either keep the test or remove the tag.

github run

@mvvmm
Copy link
Contributor Author

mvvmm commented Mar 16, 2026

/bonk please review this PR for any regressions or issues otherwise

Copy link
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted 2 inline suggestions below.

@ask-bonk
Copy link
Contributor

ask-bonk bot commented Mar 16, 2026

Review posted on PR #28921 with 2 inline suggestions:

LOW (2 items):

  • astro.config.ts line 160 — Duplicate exclude glob pattern. **/index.md (added on line 148) and **index.md (pre-existing on line 160) are redundant. Suggested removing the old one.
  • src/pages/llms.txt.ts lines 13-18 — allUrlPrefixes set may include undefined values if any directory entry has a falsy url. Suggested adding an explicit type guard to the filter.

The previous review's concern about the rel='alternate' test being removed has been addressed — the test at worker/index.worker.test.ts:177 is still present. The MDX content changes are clean: no unescaped characters, correct code block languages, valid internal links, and proper component imports.

github run

mvvmm and others added 3 commits March 16, 2026 09:43
Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
@mvvmm mvvmm merged commit 3eddc36 into production Mar 16, 2026
9 checks passed
@mvvmm mvvmm deleted the use-md-for-agents-for-all-md branch March 16, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants