#14666·wagtail

Ways to allow Pages and StreamField blocks to render themselves in other formats besides HTML

Author: StormhegCreated Sep 30, 2026Updated Sep 30, 2026
Labelstype:Enhancementcomponent:StreamfieldSprint topicstatus:Needs Maintainer Feedback

Problem statement

Large language models (LLMs) are everywhere and extensively used today. People use LLMs to search for information instead of using search engines like Google.

In order for websites to be properly understood by LLMs, serving them as well-structured content, preferably as minimal markdown documents is recommended^1. This calls for new approaches to present content to visitors, whether they are human or machine.

I propose we extend Wagtail’s ability to render pages and StreamField blocks as HTML to other formats. Today there is a need for markdown, but the ability to have alternative representations of content can be more widely useful. For example this issue on wagtail.org would benefit from the ability to render ‘RSS-reader compatible’ (simplified HTML) representation of blog posts.

Proposed Solution

Implement the ability to let blocks and pages render themselves in different formats. Not sure what the API for this should look like exactly. I’m assuming that each format would have their own Django/Jinja template and get_context can return different context depending on the requested format.

Rough sketch of what I imagine the API could look like.

python
from wagtail import blocks
from wagtail.models import Page

class TextPage(Page):
    # Allow format to be specified for rendering?
    def serve(self, request, format="html", *args, **kwargs):
        pass


class TextBlock(blocks.StructBlock):
    text = blocks.RichTextBlock()

    class Meta:
        # CURRENT: one template for all
        # template = "blocks/text_block.html"

        # SUGGESTED: templates by format identifier (e.g., "html", "markdown")
        templates = {
            "html": "blocks/text_block.html",
            "markdown": "blocks/text_block.md"
        }

    # Allow get_context to accept a format parameter to customize the context passed to the template?
    def get_context(self, value, parent_context=None, format="html"):
        context = super().get_context(value, parent_context=parent_context)
        return context

Alternative solutions

guide.wagtail.org makes markdown versions of its pages available. Example: https://guide.wagtail.org/en/releases/new-in-wagtail-8-0/markdown/.

The developers of that site did this by creating a MarkdownRouteMixin for their pages. They handled the rendering of blocks with special template code to handle each block type, which works because their content structure is very simple. However, this doesn’t scale well to many different block types or lots of nested blocks

Additional context

Right now I’m working on implementing the per-page markdown route recommendation from specification.website using the apis and means available in Wagtail today. I can probably find ways to make this work. I’m not asking to make Markdown rendering of pages a first-class citizen in Wagtail, I just want to start the discussion if having multiple rendered representations of a block is something Wagtail should support. And if we should, what should the api for it look like?

Let's see if there is appetite for this enhancement and start the discussion!

Working on this

Contribute to the discussion to help this move forward. Explain your use cases, discuss possible solutions, research how to adapt existing code, or compatibility concerns.

Once others agree with the proposed changes, anyone can contribute to this. View our contributing guidelines. Add a comment to the issue to explain what approach you are taking.