Let crawlers read the Ask Nedi page, prefill question links

Merged
KT
2mo ago
+4804-567

Summary

  • robots.txt: the bare /docs/ask-nedi page becomes crawlable; every question URL stays blocked (/docs/ask-nedi?…, /docs/ask-nedi/…, /?q=, /?question=, and the same two parameters after another one, /?…&q= and /?…&question=). The permanent root redirect (/ → /docs/ask-nedi) no longer ends at a robots-blocked page, so search engines can follow it into the documentation.
  • Ask Nedi question links: ?q= and ?question= now prefill the Nedi input instead of sending the question. A person sends it with Enter or the send button, so crawlers that render pages can never trigger LLM requests, whatever robots.txt they honor. The prefill runs in an animation frame that is cancelled if the page unmounts first, so a navigation never edits the next page's URL.
  • Ask Nedi text for crawlers: the server-rendered fallback keeps "Loading Ask Nedi..." and adds one sentence with links to the Complete Product Description and Getting Started, for clients that do not run JavaScript.
  • Generated-output boundary: docs/ask-nedi.mdx is hand-maintained (ingest preserves part_of_learn pages), so ordinary pull requests may change it. A test keeps the Learn-owned list equal to the pages ingest preserves; every other docs/** change still needs the ingest automation PR.
  • Absolute Learn links are checked during ingest: after the final reconciliation, ingest checks every absolute learn.netdata.cloud link in the published pages (inline and reference-style links, HTML href attributes, and bare URLs that remark-gfm turns into links) against page routes, heading anchors (ATX and Setext headings, slugged the way Docusaurus does), netlify.toml redirect sources and static files (ingest/learn_links.py). Findings are attributed to the page's source repository and honour --fail-links / --fail-links-<repo>, so netdata's Docs Broken Link Check fails in the netdata PR that adds a dead absolute link, instead of Learn's rendered link check failing later on unrelated Learn PRs (as happened with netdata/netdata#24130).
  • /llms.txt and /llms-full.txt: ingest writes both into static/ in the shared reconciliation step (ingest/llms_files.py). llms-full.txt is the Complete Product Description as plain markdown with absolute links; llms.txt indexes it and the hand-written docs in sidebar order, with one entry per integration catalog overview page (~70 KB). Both are pipeline-owned (generated-output boundary; the recovery check hashes them whenever they exist, since they appear only once an ingest finds the product description page). /llms-full.txt gets a Link: rel=canonical header pointing to the Complete Product Description page (no noindex, per the zero-noindex rule).
  • Redirects for dead URLs that still receive backlinks: 213 static rules (static.toml, copied into the static section of netlify.toml). The dead URLs and their backlinks come from the SEO service's backlink inventory; each target was checked against the page history (same source file where it still exists, the successor section where a page was split, no rule where no page carries the content) and is a final page, not another redirect. Cross-site: /academy to the www Academy, and the two changelog URLs to the Agent CHANGELOG.md on GitHub, as Learn already does for its older changelog URL. Spellings with an encoded fragment (%23) are not added (the redirect checker rejects them). The six /docs//… rules could never match (doubled slash); they are removed together with the legacy catalogue keys that generate them.
  • Corrected generated redirects: 77 existing rules (generated from the legacy catalogue, older static rules, and three of the backlink rules above) sent a dead page to an unrelated or generic page although a page with its content, a native page for the same product, or the page that now covers its subject exists. Static rules with the same source now override them: the streaming README spellings go to the Parent-Child Configuration Reference (same source), apps.plugin README spellings to Applications, the old "Collect application metrics" hub to Monitor Anything (netdata's own replacement link), freebsd.plugin README spellings to the Operating Systems collectors instead of an eBPF article, 29 Prometheus-exporter pages to the native page for the same product (SNMP device profiles, CloudWatch and Azure Monitor services, Memcached, Oracle, OpenLDAP, X.509, IPMI, Nagios scripts, NVIDIA GPU and others), the generic SQL exporter page to the native SQL databases (generic) collector, the python.d ZScores and ChangeFinder pages to Anomaly Detection, the streaming concept pages to Netdata Parents, netdata-for-IoT to Edge Device Monitoring, the Pi-hole guide to the Pi-hole collector, and the old eBPF integrations grid to the eBPF article. Three more spellings of these pages had no rule and returned 404; they get one. The system metrics and proc.plugin README spellings go to /docs/collecting-metrics, which the redirect policy pins for their other spellings.
  • Pinned redirects to the page with the content: three repairs that config/redirect-policy.json pins now go to the page that carries the old page's content. Both pinned spellings of "Run-time troubleshooting with Functions" go to the Live tab (/docs/dashboards-and-charts/tabs/live) instead of /docs/live-view: the Live tab publishes the same file, renamed twice (netdata/netdata#17653, netdata/netdata#21872). Static rules send the page's four other spellings, which the legacy catalogue maps to /docs/live-view, and /docs/dashboards-and-charts/tabs/top, the page's last route before the second rename (404 today), to the Live tab as well; its earlier route, /docs/dashboards-and-charts/top-tab, already goes there. /docs/collect/container-metrics ("Collect container metrics", which explained cgroups.plugin) goes to Containers and cgroups, like its two other spellings, instead of the Containers and VMs integrations grid. The policy keeps its 27 pinned repairs, and an accepted_review_corrections entry records the change.
  • Code stays code in ingested pages: ingest escaped { and < for MDX with a regular expression that paired triple backticks, and applied the <=, %<, <-> and autolink rewrites to code as well, so 20 code lines on 12 published pages show a stray backslash today (for example ROWNUM \<= 1 on the Oracle DB page and $\{status} in the AWS SNS example). ingest/mdx_code.py finds fenced code and code spans the way Docusaurus' MDX parser does; every MDX rewrite now applies to prose only, an already escaped character is not escaped again, and llms-full.txt undoes the escapes with the same code ranges. The 12 pages change with the next ingest pull request.
  • Catalogue redirects follow a page that moves: when a page the legacy catalogue points to moved, the ingest stopped with Conflicting redirect identity, after it had already appended to the catalogue. As the README documents, a resolved catalogue entry now replaces the tracked target for its route, in place so the rule order stays the same; two spellings of one route that resolve to different pages fail the legacy redirect gate before anything is written.
  • SEO remediation contract: accepted_review_corrections entries record each change; the root redirect, the sitemap exclusions of / and /docs/ask-nedi, and the zero-noindex rule are unchanged.

Why

The root URL is Learn's most-linked URL, and AI assistants fetch it often; today it redirects to a page crawlers may not read. Question links were the reason Ask Nedi was blocked: rendering a ?q= URL asked Nedi automatically. With prefill, the bare page can be crawled safely. The llms files give AI tools the whole product description in one file and an index of the docs; the link check makes dead absolute links fail where they are introduced.

Testing

  • Full local ingest of this branch from all six documentation repositories (--local-repo with netdata master 47605d117e, the on-prem repository and the four public ones), then npm run build:netlify (Node 22): every page compiles and all post-build gates pass (3,855 redirects verified against 6,262 published routes; 829,521 rendered internal links avoid every redirect source; zero noindex directives and no robots-blocked sitemap URL); site build gate: 0 findings, 0 regressions over 2,022 pages. The ingest reports only the known dead absolute link (the Redis service discovery URL, fixed by netdata/netdata#24174) and exits 1 for it; the legacy redirect gate resolves 3,561 catalogue entries, keeps 3 stale ones and fails none; netlify.toml, the legacy catalogue and the recorded mapping come out byte-identical.
  • MDX escaping, previous and new code on the same inputs: 12 of the 2,017 pages differ, only in the 20 code lines that lose a stray backslash (as the MDX parser reads the pages, 21 escapes inside code before, none after). Parsed with Docusaurus' MDX pipeline, 2,005 pages are identical and the other 12 differ only in 15 code values, each the previous value without the escape; no prose changes. llms.txt, llms-full.txt and the generated map are byte-identical.
  • ingest/mdx_code.py against the MDX parser: its code ranges equal the code and inlineCode nodes on all 2,017 pages of the current docs and of the new ingest output, and on 104 edge cases (fences in blockquotes, list items and directives; nested, indented and unclosed fences; code spans across lines and in table cells; CRLF line endings).
  • Ingest unit tests: 145 run; the only failures are the suite's 6 pre-existing ones in test_seo_grid_generation.py, identical without these changes. They include ingest/test_learn_links.py, ingest/test_llms_files.py, ingest/test_ingest_workflow.py (the workflow's recovery snapshot with and without the llms files), ingest/test_mdx_code.py, ingest/test_mdx_escaping.py (the code of the 12 affected pages, prose escapes, no double escaping, idempotence) and the moved-page and route-spelling cases in ingest/test_legacy_redirect_gate.py (one moves a real page with 15 catalogue routes); the new escaping and redirect cases fail on the previous code. test_escape_mdx_braces.py now tests ingest's function instead of a copy of the old one (54 cases pass).
  • Link check against the real toolchain: on the 2,017 docs pages, the Learn links the check extracts and the ordered heading ids it computes equal what Docusaurus's MDX pipeline (remark-gfm, remark-directive and its heading plugin) renders; the check reports exactly one dead absolute link (the Redis service discovery URL, fixed by netdata/netdata#24174).
  • llms-full.txt built from the ingested Complete Product Description page matches the netdata source line for line (1,240 lines) apart from link destinations and the source's own \<5% escape.
  • --regenerate-grids-only after that ingest: fixed point over 2,024 generated outputs (the docs corpus, both llms files, the generated map and sidebar state, netlify.toml). A simulation of the next full ingest's redirect stage against the recorded mapping (catalogue gate, merge, cleanup, reconciliation) reproduces netlify.toml byte for byte.
  • vitest (src/seo, src/components/Nedi): 210 pass, 1 skipped (needs BUILT_SITE_DIR). The global coverage threshold fails identically on master.
  • After the pinned-redirect change (on the committed docs, without a new full ingest): npm run build:netlify passes all post-build gates (3,856 redirects against 6,262 published routes; site build gate: 0 findings over 2,022 pages); --regenerate-grids-only is a fixed point over the same 2,024 outputs; the next-ingest redirect simulation reproduces netlify.toml byte for byte (3,561 catalogue entries resolved, 3 retained, none failed); all 11 spellings of the two pages reach their target in one hop; the ingest unit tests and vitest results are unchanged.
  • robots semantics are covered by src/seo/renderedIndexability.test.js on the real static/robots.txt: /, /?utm_source=… and /docs/ask-nedi allowed; /docs/ask-nedi?q=…, /docs/ask-nedi/…, /?q=…, /?question=… and the same parameters after another one blocked.

Merge order

  1. netdata/netdata#24174 (Redis service discovery link). Until it merges, netdata's Docs Broken Link Check would fail on every docs PR once this check is live.
  2. This PR. The next ingest PR then adds static/llms.txt and static/llms-full.txt.

Note: docs/ask-nedi.mdx is part of the source corpus that the sidebar state hashes, so after this PR merges --regenerate-grids-only refuses until the next full ingest refreshes the state. The merge push triggers that ingest (ingest.yml runs on **/*.mdx and static.toml changes), and its recovery step runs after the full ingest, so CI is not affected.

Summary by CodeRabbit

  • New Features
    • Ask Nedi can prefill a question from a q or question link and focus the chat input; the question is not sent automatically.
    • Documentation is available in /llms.txt and /llms-full.txt.
  • Bug Fixes
    • Updated legacy documentation redirects to lead to more relevant current pages, including routes that follow pages when they move.
    • Improved documentation formatting so code examples remain intact while prose is prepared for display.
    • Updated crawl rules to allow the Ask Nedi page while blocking question-query URLs and nested paths.