Skip to content

Serve Markdown at page URLs

Answer agents that ask for Markdown at a page's own URL, by rendering your docs on request.

AI-generated · awaiting reviewUpdated

Every page already has a Markdown version at /<slug>/index.md. With Markdown negotiation, a request to the page’s own URL with Accept: text/markdown gets that Markdown too, so an agent doesn’t need to know the .md convention.

Prerequisites

  • site set to your production origin in the Nimbus config
  • A host with a server adapter: Cloudflare, Netlify, Node or Vercel

Steps

  1. Add a server adapter

    Skip this step if the site already has one. For Cloudflare:

    npx @cloudflare/nimbus-docs add adapter-cloudflare

    Other hosts use adapter-netlify, adapter-node or adapter-vercel.

  2. Render the docs on request

    In astro.config.ts, set the docs collection to render on request:

    astro.config.tsts
    const nimbusConfig = defineNimbusConfig({
      site: "https://docs.example.com",
      // …
      rendering: { collections: { docs: "request" } },
    });
  3. Build and deploy

    Deploy the server and the generated Markdown files together. Off Cloudflare, the server reads the Markdown from site, so the files must be reachable there.

Verify

Request a page with Markdown first in the Accept header:

curl -I -H 'Accept: text/markdown' https://docs.example.com/guide/
HTTP/2 200
content-type: text/markdown; charset=utf-8
vary: Accept

If content-type is text/html, the page is still prerendered: check that its collection is set to "request". A browser’s Accept: */* always gets HTML.

Static sites

A prerendered page is served before any server code runs, so it can’t negotiate. On Cloudflare, turn on Markdown for Agents for the zone instead: Cloudflare converts the HTML when an agent asks for Markdown.

API references

Generated API references render on request only with the Cloudflare adapter. On other adapters, keep API collections set to "build" while the docs use "request".

Next steps

Type to search…

↑↓ navigate↵ selectEsc close