You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cb3092c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(llm): Follow Vercel's Markdown and agent discovery guidance (#20930)
## DESCRIBE YOUR PR
Brings docs.sentry.io in line with Vercel's [Markdown and Agent
Discovery](https://vercel.com/docs/agent-resources/markdown-access)
guidance and the [llms.txt v2](https://llmstxt.org/) link relations. We
already had the `.md` exports, content negotiation, `llms.txt`, and the
**View as Markdown** button. This PR adds the parts that were missing.
**Content negotiation honors quality values.** The middleware used to
serve Markdown whenever `Accept` contained `text/markdown`, and to any
recognized AI user-agent regardless of `Accept`. Now
(`src/lib/contentNegotiation.ts`):
- Markdown is served when `Accept` ranks `text/markdown` at or above
`text/html`. A tie goes to Markdown, so `text/markdown, text/html, */*`
(Claude Code's WebFetch) still gets Markdown, but `text/html,
text/markdown;q=0.9` now gets HTML.
- A recognized AI agent whose `Accept` names neither format (`*/*`,
empty) gets Markdown. One that explicitly asks for `text/html` gets
HTML.
**Markdown responses** (negotiated or `.md`) set `Vary: Accept` and a
`Link` header with `rel="canonical"` (the HTML page) and
`rel="describedby"` (`/llms.txt`). Before, the canonical link was only
on `.md` URLs.
**HTML pages** advertise their Markdown version two ways: a `Link`
response header (`rel="alternate"; type="text/markdown"` plus
`rel="describedby"`), and the same links as `<link>` tags in `<head>`.
The header lets agents that run `curl -I` find the Markdown without
parsing HTML.
**Discovery index.** `scripts/generate-llms-txt.mjs` now also writes
`/sitemap.md`: every visible page, nested like the sidebar, with its
description and `.md` URL (~340 KB, ~2,000 pages; Vercel's is ~540 KB).
Every page export ends with a footer linking `/sitemap.md` and
`/llms.txt`, and `llms.txt` and the Markdown soft-404 link the sitemap.
`specs/llm-friendly-docs.md` and `AGENTS.md` are updated to match.
### Notes for review
- **Behavior change for agents that send browser-style `Accept`
headers.** An agent matching `AI_AGENT_PATTERN` that sends
`text/html,...,*/*;q=0.8` now gets HTML, not Markdown. This is what
Vercel's guidance asks for ("A recognized AI agent receives HTML when it
requests `text/html`"). Before merging, check `docs.request.classified`
/ the `Middleware request processed` logs for which agents send
`text/html` without `text/markdown`, to see how much traffic moves to
HTML. If that's too much, `shouldServeMarkdown` can keep the user-agent
override for agents.
- **No `Vary: Accept` on HTML responses.** The App Router page renderer
calls `res.setHeader('Vary', …)`, which replaces any `Vary` the
middleware sets, so a middleware `Vary` on HTML is dropped (confirmed on
`next dev`). Markdown responses keep `Vary: Accept`, which stops caches
from serving Markdown to browsers. Vercel's own docs set `Vary: Accept`
only on Markdown responses too.
- **The footer changes every export once**, so the first build after
merge re-uploads every file to R2 and logs the ">10% different hash"
warning.
- **Left out on purpose:** the Vercel-specific parts (`graph.json` /
`.graph.md` cross-link maps, the `vercel docs` CLI,
`.well-known/ai-catalog.json`), the extra frontmatter fields
(`last_updated`, `type`, `prerequisites`, `related`) that we don't have
data for, and `llms-full.txt`.
## IS YOUR CHANGE URGENT?
- [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD
- [ ] Other deadline: YYYY-MM-DD
- [x] No deadline: Not urgent, can wait up to 1 week+
## PRE-MERGE CHECKLIST
- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)
<!-- junior-request-attribution:start -->
via @sergical.
<!-- junior-request-attribution:end -->
<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0CDFPETHS4%3A1795221617.574909 -->
--
[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0CDFPETHS4%3A1795221617.574909)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0CDFPETHS4%3A1795221617.574909/?project=4510944073809921)
<!-- junior-session-footer:end -->
---------
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Sergiy Dybskiy <3760543+sergical@users.noreply.github.com>
0 commit comments