Serve AI agents with Markdown instead of HTML, reducing token usage ~80%. Implements the Markdown for Agents specification by Cloudflare with Content Signals headers.
---
title: "How to Train Your Dragon"
author: "Jane Smith"
date: "2026-01-15"
categories:
- Tutorials
tags:
- AI
- WordPress
url: "https://example.com/how-to-train-your-dragon/"
---
This is the **full post content** converted from Gutenberg blocks
to clean Markdown. Lists, headings, images, code blocks — all preserved.
- Bullet points work
- [Links work](https://example.com)
- `inline code` worksHTTP/1.1 200 OK
Content-Type: text/markdown; charset=utf-8
Vary: Accept
X-Markdown-Tokens: 342
Content-Signal: ai-train=yes, search=yes, ai-input=yes
X-Robots-Tag: noindex
Link: <https://example.com/post/>; rel="canonical"
- Content negotiation — responds with Markdown when
Accept: text/markdownheader is present - Static endpoint —
?format=mdURL parameter for any post/page - Plain text fallback —
?format=txt//slug/index.txtserves identical Markdown withContent-Type: text/plainfor clients that don't supporttext/markdown - Pretty URLs —
/slug/index.mdand/slug/index.txt(with pretty permalinks enabled) - Discovery tags —
<link rel="alternate" type="text/markdown">and<link rel="alternate" type="text/plain">in<head> - YAML frontmatter — title, author, date, categories, tags, URL
- HTTP headers —
Content-Type,Vary,X-Markdown-Tokens,Content-Signalper spec - Token estimation — approximate token count in response header
- Caching — Transients-based, invalidated on post save
- Request logging — tracks all markdown requests with bot identification, filtering, sorting, pagination
- Bot identification — recognizes 24+ AI bots (GPTBot, ClaudeBot, Googlebot, PerplexityBot, etc.)
- Statistics dashboard — HTML vs Markdown comparison, bot distribution chart, top posts, token stats
- Settings UI — tabbed interface: settings, request logs, statistics
- Auto-update — automatic updates from releases (no ZIP uploading needed)
- Clean uninstall — removes all data (table, options, cache) when plugin is deleted
- Taxonomy archives — category, tag and custom taxonomy pages served as Markdown (post list with frontmatter, pagination, subcategories)
- WooCommerce — products get
add_to_cart_url,price,currency,sku,in_stockin frontmatter; product category archives include price/SKU per item
Install:
- Download
markdown-for-agents.zipfrom the latest release - WordPress admin → Plugins → Add New → Upload Plugin → Activate
Test:
# Via URL parameter
curl 'https://your-site.com/hello-world/?format=md'
# Via Accept header (how AI agents do it)
curl -H 'Accept: text/markdown' 'https://your-site.com/hello-world/'
# Pretty URL
curl 'https://your-site.com/hello-world/index.md'
# Plain text (same content, Content-Type: text/plain)
curl 'https://your-site.com/hello-world/index.txt'Configure which post types and taxonomies are enabled in Settings → Markdown for Agents.
- AI agent requests a page with
Accept: text/markdownheader (or?format=md) - Plugin intercepts at
template_redirect(priority 5) - Post content is rendered through WordPress (
apply_filters('the_content')) - HTML is converted to Markdown via league/html-to-markdown
- YAML frontmatter with post metadata is prepended
- Response is served with proper headers and cached via WordPress Transients
| Option | Default | Description |
|---|---|---|
| Enable plugin | On | Master switch |
| Post types | Posts, Pages | Which post types serve Markdown |
| Taxonomies | Categories, Tags | Which taxonomy archives serve Markdown |
| Cache TTL | 3600s | How long converted Markdown is cached |
| Canonical Link header | On | Send Link: rel="canonical" pointing to HTML page |
| Beta updates | Off | Opt-in to receive pre-release (beta/RC) updates |
Enable the product post type in settings. Product frontmatter includes add-to-cart URL, price, currency, SKU and stock status. Taxonomy terms (product_cat, product_tag) are automatically mapped to categories and tags.
docker compose up -d
# WordPress at http://localhost:8080 (admin/admin)See docker-compose.yml for the full dev environment setup.
- Page builder compatibility
- Cloudflare: Markdown for Agents — announcement blog post
- Cloudflare: Spec reference — technical specification
- Content Signals — HTTP header standard for AI content permissions
GPL v2 or later