Skip to content
AddHunt
WordPress plugins

Post Content to Markdown

WordPress plugin serving posts and feeds as Markdown

Works with WordPress pluginOpen source

  • Open source

In short

Post Content to Markdown is an open-source WordPress plugin from Roots that gives every post and feed a Markdown version through standard content negotiation. It is for site owners and developers who want AI agents and scripts to read their content without theme markup.

What you get

  • Markdown via Accept header, query parameter or .md URL
  • Link header and head tag pointing to the Markdown version
  • Renders Gutenberg blocks before converting
  • Strips syntax-highlighter markup from code blocks
  • Object-cache storage keyed on a content hash
  • Markdown feed at /feed/markdown/

The details

Post Content to Markdown gives a WordPress site a Markdown version of its content while reusing the normal post URLs, so there is no extra API to maintain. The reasoning is that AI agents handle Markdown better than rendered HTML: there is no theme chrome to work around and fewer tokens to process.

Three ways to ask for Markdown

  • Send an Accept: text/markdown request header
  • Add ?format=markdown to the URL
  • Append .md to a post URL, such as /hello-world.md

The HTML page also points to its Markdown alternative with a Link response header and a matching link element in the head, so agents that never send the Accept header can still discover it.

Conversion details

Gutenberg blocks are rendered before conversion, which keeps dynamic blocks, embeds and tables intact. Wrapper markup added by syntax highlighters such as Prism and highlight.js is stripped from code blocks. Converted output is stored in the object cache, for example Redis or Memcached, keyed on a hash of the content, so repeat requests skip rendering and conversion altogether.

Feeds work the same way, and there is a dedicated Markdown feed at /feed/markdown/. The plugin comes from Roots, the team behind Bedrock and Sage, and is released under the MIT license.

Alternatives to Post Content to Markdown

All alternatives

Questions

How do AI agents get the Markdown version?

They can send an Accept: text/markdown header, add ?format=markdown, or request the .md URL. HTML pages also link to the Markdown version for agents that do not use the header.

Does it handle block editor content?

Yes. Gutenberg blocks are rendered first and then converted, so dynamic blocks, embeds and tables are preserved.

Does the conversion slow the site down?

Results are cached in the object cache, such as Redis or Memcached, keyed on a content hash, so repeat requests skip the conversion.

More like this