Making agent-friendly pages with content negotiation
Feb 3, 2026

Summary
This post details the implementation of content negotiation in Next.js to serve markdown versions of web pages to agents. It includes a `next.config.ts` rewrite rule to detect the `Accept: text/markdown` header and a route handler (`app/blog/md/[...slug]/route.ts`) to convert CMS rich text to markdown on the fly. It also introduces markdown sitemaps for agent discovery, with examples for blog posts (`app/blog/sitemap.md/route.ts`) and hierarchical documentation (`app/docs/sitemap.md/route.ts`). The post highlights the significant performance benefits (99.37% payload reduction) and mentions the use of Next.js 16 remote cache for synchronization.