Skip to content

Instantly share code, notes, and snippets.

@birkin
Created March 20, 2026 23:12
Show Gist options
  • Select an option

  • Save birkin/d45c24b00b1a2590c766887dece3a51a to your computer and use it in GitHub Desktop.

Select an option

Save birkin/d45c24b00b1a2590c766887dece3a51a to your computer and use it in GitHub Desktop.
implications of growing use of `accept: text/markdown`.

Implications of Accept: text/markdown for Django-delivered HTML content

Based on Cloudflare’s “Introducing Markdown for Agents” article, the practical implication for a Django developer is that your HTML pages may increasingly want a second negotiated representation aimed at AI agents and machine consumers: text/markdown.

Core takeaway

Historically, many Django apps have treated a page as either:

  1. human-facing HTML, or
  2. API JSON.

This article suggests a third delivery pattern is becoming more relevant:

  1. agent-facing markdown, negotiated from the same canonical resource.

That does not mean markdown should replace HTML. It means a given URL may reasonably offer:

  • text/html for browsers
  • text/markdown for agentic clients
  • application/json for explicit programmatic APIs where appropriate

What this changes conceptually

1. Treat representation-negotiation as a first-class design concern

In Django, a page route that currently only returns HTML may now want content negotiation based on the Accept header.

For example, a resource like:

/products/widget-123/

could return:

  • HTML for browsers
  • Markdown for agents that send Accept: text/markdown

That pushes ordinary website views a little closer to REST-style representation thinking.

2. Your site content may need a cleaner content-model / presentation split

If you want to emit both HTML and markdown from the same URL, you will benefit from keeping:

  • canonical content in structured fields
  • page chrome separate from main content
  • navigation, promos, and interaction widgets out of the core body representation

A template that is mostly presentation glue is easy for browsers, but harder to repurpose cleanly for markdown. A stronger content model makes multi-representation delivery much easier.

3. Some pages are better candidates than others

Good candidates for a markdown representation:

  • documentation pages n- blog posts
  • help pages
  • policy / informational pages
  • product-detail pages with mostly textual content
  • knowledge-base articles

Poorer candidates, or pages needing extra work:

  • heavily interactive dashboards
  • JS-dependent applications
  • map-driven interfaces
  • complex e-commerce flows
  • pages whose meaning depends on client-side state

For those, you may still need HTML only, or a separate JSON/API representation.

4. Your website and your API become less separate than they used to be

This article points toward a future where some user-website endpoints become lightweight machine-readable interfaces, even when they are not formal APIs.

That means a Django site may increasingly expose information through:

  • browser HTML
  • negotiated markdown
  • JSON endpoints
  • feeds / sitemaps / structured metadata

The boundary between “site” and “API surface” gets blurrier.

Django-specific delivery implications

Pattern A: Negotiate in the same view

A Django view can inspect request.headers.get("Accept") and choose a response format.

This is attractive when:

  • the underlying resource is the same
  • markdown is just an alternate rendering
  • you want one canonical URL

Important details:

  • return Vary: Accept
  • keep cache keys representation-aware
  • ensure tests cover multiple Accept values

Pattern B: Separate URLs, shared content source

You might instead expose:

  • /docs/foo/ → HTML
  • /docs/foo.md or /docs/foo/markdown/ → markdown

This is simpler operationally, though less elegant than true negotiation.

It can be a good fit if:

  • your CDN/proxy setup is simple
  • you want easy manual inspection
  • you do not want to rely on Accept handling across the whole stack

Pattern C: Keep HTML as origin output, add markdown at the edge

The Cloudflare article is explicitly about converting HTML to markdown at the edge. Even if you do not use Cloudflare’s feature, the architectural idea is important:

  • Django can remain your HTML origin
  • another layer can derive markdown for agents

This reduces application changes, but also means your markdown output is derivative rather than intentionally authored.

My view: this is a good transitional step, but a deliberately authored or app-generated markdown representation is often better for high-value pages. The common opposing view is that edge conversion is “good enough” and simpler to ship, especially if the site already has clean semantic HTML.

Practical design guidance for Django apps

1. Build around canonical content, not canonical HTML

If the real asset is an article, doc page, or product description, store it in a structured form that can render into multiple outputs.

Examples:

  • title
  • summary
  • sections
  • body blocks
  • metadata
  • related links

The more your application treats HTML as only one renderer, the easier additional delivery modes become.

2. Consider markdown as a companion representation, not your source of truth

For many Django applications, the best setup is:

  • structured database content as source of truth
  • HTML renderer for humans
  • markdown renderer for agents

That avoids lossy HTML-to-markdown back-conversion inside your app.

3. Keep agent-facing markdown intentionally lean

A markdown representation should usually exclude:

  • site-wide nav
  • footer boilerplate
  • cookie banners
  • marketing slots
  • unrelated CTAs
  • decorative UI text

It should include:

  • title
  • canonical summary
  • main body
  • key metadata
  • meaningful links
  • structured headings

That is one of the article’s strongest practical lessons: agent-oriented output should minimize useless token spend.

4. Think beyond markdown alone

The article is persuasive, but markdown should not crowd out other machine-friendly delivery options.

Depending on your use case, you may also want:

  • JSON / JSON:API / HAL / custom API responses
  • RSS/Atom feeds
  • schema.org structured data in HTML
  • XML feeds for specialized consumers
  • plain-text or simplified HTML variants for special clients

My view is that markdown will be most useful for general-purpose agent consumption of page content, while JSON remains stronger for strict contracts and transactional integrations. A common opposing view is that a well-designed JSON API makes markdown largely unnecessary. That is true for explicit integrations, but less true for broad agent consumption of content pages.

Operational implications

Caching

If one URL returns both HTML and markdown, your cache strategy must distinguish representations. Otherwise you risk serving markdown to browsers or HTML to agent clients.

At minimum:

  • vary on Accept
  • verify reverse-proxy/CDN behavior
  • ensure ETags or cache keys are representation-specific

Observability

You may want to measure:

  • how often Accept: text/markdown appears
  • which user agents request it
  • whether markdown traffic correlates with AI crawlers or internal agents
  • token-size or body-size savings if you track them

SEO / discoverability / policy

The article also signals a broader trend: content owners may want to express usage preferences and machine-consumption policy more explicitly.

For Django sites, that may eventually mean paying more attention to:

  • crawler policy
  • AI-use policy
  • content licensing signals
  • consistency between robots.txt, metadata, headers, and API terms

Security and data-leak surface

A new representation is a new surface area.

Be careful that markdown output does not accidentally include:

  • admin-only notes
  • hidden UI text
  • internal links not meant for publication
  • debug artifacts
  • raw user-generated content that needs sanitizing

Do not assume “it is just another rendering” means it is risk-free.

Where this is especially relevant for Django teams

This matters most if you build:

  • public documentation
  • editorial content sites
  • developer portals
  • knowledge bases
  • searchable institutional / repository content
  • product catalogs with descriptive content

It matters less for applications whose value lies mainly in authenticated interaction rather than published content.

Concrete next steps you could take

  1. Audit which Django pages are fundamentally content resources.
  2. Decide whether each should support only HTML, HTML+markdown, or HTML+JSON.
  3. Refactor view logic so core content assembly is independent of the template.
  4. Add a markdown renderer for a narrow slice first, such as docs or articles.
  5. Return Vary: Accept wherever you negotiate on Accept.
  6. Test CDN/cache behavior carefully.
  7. Measure usage before expanding the pattern site-wide.

Bottom line

The article’s biggest implication is that a Django website may increasingly need to serve multiple representations of the same content resource, not just HTML for people and JSON for APIs. text/markdown becomes a plausible middle ground: human-authored content, optimized for machine reading, without requiring every consumer to use a formal API.

For many Django developers, the most durable architectural response is:

  • keep content structured
  • render HTML intentionally for people
  • render markdown intentionally for agents
  • use JSON where strict machine contracts are required

That is less a gimmick than a shift in delivery architecture: websites are starting to function as content APIs even when they do not look like traditional APIs.


Notes

  • prompt:
    i'm a developer who often uses django to build user-websites and APIs. 
    
    what implications does this article have for additional ways I might deliver my html content?
    
  • model: "ChatGPT-5.4-Extended-thinking; 2026-March-20"

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