Skip to content

feat: add navigation header to per-page .md files#2596

Open
marekh19 wants to merge 6 commits into
masterfrom
feat/context-links-in-markdown-pages
Open

feat: add navigation header to per-page .md files#2596
marekh19 wants to merge 6 commits into
masterfrom
feat/context-links-in-markdown-pages

Conversation

@marekh19
Copy link
Copy Markdown
Contributor

@marekh19 marekh19 commented May 28, 2026

Resolves #2557

Prepends a small frontmatter block to every per-page .md served by docs.apify.com so AI agents reading a single page can follow parents / children / previous / next links without having to fetch llms.txt first. Shape modeled on Vercel's docs (vercel.com/docs/builds/build-features.md): flat YAML-style frontmatter, no nested trees, links are inline [Title](url.md) so the agent can pick by title without a probing fetch.

Implemented as scripts/addNavHeaders.mjs in the postbuild chain. Runs after @signalwire/docusaurus-plugin-llms-txt writes both the per-page .md files and llms-full.txt, so editing only the per-page files leaves llms-full.txt untouched (the issue requires the header to stay out of it). Reads the real left-menu trees from .docusaurus/docusaurus-plugin-content-docs/*/p/*.json, so labels, ordering, and prev/next exactly match the live sidebar.


A few design decisions worth recording:

Header shape — modeled on Vercel's docs: flat YAML-ish frontmatter, links as inline [Title](url.md) so an agent can pick by title without a probing fetch.

Children stay flat (direct only). A full recursive sub-tree explodes on exactly the pages an agent lands on first — /api/v2 would carry 269 nested links, /platform/integrations 66, /platform/actors 57. That pollutes the header and bloats neighbouring content for no real gain: the agent can walk down one hop at a time via each page's own children.

Parents go all the way up. The opposite trade-off — a breadcrumb is a single chain bounded by site depth (~5 max), so there's no blow-up risk. Every page now chains llms.txt root → section landing → category ancestors, giving a reliable "zoom back out" path. This also fixes 83 top-level pages that previously had no parents at all.

Kept out of llms-full.txt for free by running in postbuild, after the llms-txt plugin has already written llms-full.txt from the same per-page content.

previous/next links mirror the site's prev/next buttons.


Example 👀

https://pr-2596.preview.docs.apify.com/platform/actors/running.md

@marekh19 marekh19 added the t-web Issues with this label are in the ownership of the web team. label May 28, 2026
@marekh19 marekh19 self-assigned this May 28, 2026
@github-actions github-actions Bot added this to the 141st sprint - Web team milestone May 28, 2026
@apify-service-account
Copy link
Copy Markdown
Contributor

apify-service-account commented May 28, 2026

✅ Preview for this PR (commit e1d0103e) is ready at https://pr-2596.preview.docs.apify.com (see action run).

@marekh19 marekh19 marked this pull request as ready for review May 29, 2026 12:02
@webrdaniel webrdaniel requested a review from TC-MO May 29, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-web Issues with this label are in the ownership of the web team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add context links to Markdown version of pages for AI agents

2 participants