This recipe serves a markdown representation of your HTML pages through HTTP content negotiation.
Markdown is a lightweight markup language for creating formatted text. Compared to HTML, it is easier to read, and it drastically reduces the amount of markup relative to the textual content.
With this recipe enabled, when a client sends an Accept: text/markdown request header, redirection.io converts the HTML response body to markdown on the fly and returns it with a Content-Type: text/markdown response header. Clients that do not request markdown keep receiving the original HTML. No separate markdown files are created, and the URL does not change.
Why serve markdown?
LLM-based agents, AI crawlers, and developer tools increasingly consume markdown rather than HTML. Markdown strips navigation, scripts, and layout markup, which lowers token count and gives models cleaner input. Serving it through content negotiation lets you expose a markdown version of every page without maintaining a parallel set of .md files, without duplicating URLs, and without changes to your application or build pipeline.
How this recipe works
Once installed, the recipe enables two rules on the path you configured:
- Vary on the
Acceptheader: this rule adds aVary: Acceptresponse header to all the pages under the configured path. Since the same URL can now return either HTML or markdown depending on the request, this header tells browsers, CDNs, and other shared caches to store the two variants separately, so that a client expecting HTML is never served a cached markdown response, or the reverse. - Convert HTML to markdown: when the request
Acceptheader istext/markdown, this rule converts the HTML response to markdown and sets theContent-Typeresponse header totext/markdown.
The conversion runs in the redirection.io agent, at request time, on the response your origin already returns. The quality of the output depends on the structure of the source HTML: well-structured, semantic HTML produces cleaner markdown.
Points to consider
Acceptheader matching: the conversion rule triggers whenevertext/markdownappears anywhere in theAcceptheader, regardless of its position or quality value. This is intentional: standard browsers never sendtext/markdown, so any client listing it is, in practice, asking for it. If you want a stricter behavior, edit the rule and change the condition tostarts withorequals.- Caching in front of redirection.io: the
Vary: Acceptheader is only effective if the caches between your users and the redirection.io agent honor it. Most CDNs do, but check your CDN configuration if you use custom cache keys. - Scope: apply the recipe to the parts of your website where markdown output makes sense, typically content pages such as blog posts or documentation. Application screens, forms, and pages that depend heavily on JavaScript will not convert well.
How to install this recipe on my website with redirection.io?
-
1. Configuration -
2. Installation -
3. Validation
Installing this recipe on your website requires the following steps:
In order to install this recipe, you need to:
- Configure the path to convert to markdown on-demand: define the part of your website for which markdown should be served on request. It must start with a
/. To enable the conversion for your entire website, use the/path. To restrict it to a section, use a more specific path, such as/blog/or/docs/. - Click on "Install on My Website": click the "Install on My Website" button. This will create the two associated redirection.io rules in "draft" mode.
- Review the created rules: one rule adds the
Vary: Acceptresponse header on the configured path, the other performs the HTML to markdown conversion when the requestAcceptheader containstext/markdown. Edit them if necessary. - Publish on your website: publish the rules to activate the conversion. You can then test it with
curl -H "Accept: text/markdown" https://www.example.com/blog/some-article.