Skip to content

Convert page Markdown responses from the rendered HTML - #509

Open
albinazs wants to merge 1 commit into
wagtail:mainfrom
albinazs:feature/markdown-responses
Open

albinazs wants to merge 1 commit into
wagtail:mainfrom
albinazs:feature/markdown-responses

Conversation

@albinazs

Copy link
Copy Markdown
Contributor

Follow-up to #486. Page Markdown responses (content negotiation and /markdown/ URLs) are now converted from the page's rendered HTML, with Wagtail 8.1's HTMLToMarkdownConverter. Until now, they were built from the page content alone.

Depends on the Wagtail 8.1 upgrade (separate PR), as the converter is new in 8.1. I tested this on 8.1rc1 without upgrading.

Why: today's Markdown pages leave out what visitors see around the content. Section pages don't list their pages, and nothing links to llms.txt. The homepage has 5 links in Markdown against 47 in HTML, and Releases has 0 against 16. In the agent readiness evals (#508), agents often couldn't find the right page from Markdown, and the same site without Markdown did as well or better.

Changes:

  • MarkdownRouteMixin.to_markdown_from_html converts the whole <body> (content_selector="body"), so section page listings and the links to llms.txt and llms-full.txt are kept. The converter already leaves out <nav>.
  • The feedback form and language selector get data-markdown-ignore.
  • The YAML frontmatter moves into a partial, shared by both Markdown templates.
  • to_markdown is unchanged, as llms-full.txt and the MCP server still use it.
Eval results (3 repeats, all 33 questions)
Haiku 5.5 Sonnet 5.5
Today's Markdown 80% 89%
Markdown from HTML 80% 93%
Plain site (HTML, no extras) 87% 90%
  • Sonnet did better in every repeat.
  • Haiku stays level: when sent to the site, it opens the homepage and finds no link to Releases, which is only in the menu. Linking every section from the homepage's content should fix that, as a follow-up.
  • llms.txt and llms-full.txt were used for the first time (Haiku, 6 runs), always through a link on the page.

The evals ran on a prototype using a copy of the converter adapted to Wagtail 8.0. See RESULTS.md in the evals PR.

Testing

All tests and ruff pass on Wagtail 8.1rc1, and I checked real pages from a production database copy.

AI disclosure

AI-assisted feature and running the evals.

@albinazs
albinazs requested a review from thibaudcolas October 28, 2026 13:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant