docs: fix broken links found auditing the live docs site

Merged
AL
3mo ago
+191-51

Found while browsing https://reflex.dev/docs as a reader. Everything below was reproduced against the live site and re-verified against a local build.

What was broken

1. Links inside ```python blocks repeated the /docs basename — 37 links, 5 files

rx.link(href=...) renders a ReactRouterLink whose to is joined with the router basename (/docs), so href="/docs/x" resolves to /docs/docs/x and 404s. Markdown links are plain anchors and keep working — which is why only the python-block links broke and this went unnoticed.

The worst case was Enterprise Components: every card in its link grid pointed at /docs/docs/enterprise/..., so the whole index page was dead. Also hit hosting/config_file.md, pages/overview.md, library/typography/link.md and api-reference/special_events.md.

2. Docs linked to demo apps that no longer exist

aggrid.reflex.run, aggrid.reflex.run/pivot, map.reflex.run and customer-data-app.reflex.run all return 404. The links are removed. The table docs now point at the customer data app and sales templates, which are live.

If these demos are coming back, revert that hunk rather than keeping the links dead in the meantime.

3. "Raise an issue" reported a URL that does not exist

The footer built the issue title and body from the app-relative path, so a report filed from /docs/vars/base-vars was titled Issue with reflex.dev/vars/base-vars — a URL that 404s. It now uses the public docs URL and encodes the spaces.

Tests

Three guards in docs/app/tests/test_routes.py, all checked against the real route table so a link to a nonexistent page fails instead of shipping:

  • test_python_block_links_do_not_repeat_docs_basename — no router link may carry the /docs prefix
  • test_python_block_links_resolve_to_real_routes — router links must name a registered route (example app routes like /login stay out of scope)
  • test_markdown_docs_links_resolve_to_real_routes — every ](/docs/...) prose link must resolve
  • test_docs_do_not_link_to_retired_demo_apps — the retired demo hosts stay gone
  • test_docpage_footer_issue_link_names_the_public_docs_url

Each was mutation-checked: reintroducing the original bug makes the corresponding test fail. The first version of the resolve test passed under mutation because its regex only matched href=; it was broadened to any absolute path literal, which catches the bare link-table entries in config_file.md.

Verification

  • uv run pytest tests/ from docs/app: 411 passed, 1 skipped
  • uv run pre-commit run on the changed files: ruff-format, ruff-check, codespell, pyright, ty all pass
  • reflex compile: the Enterprise Components page now emits /enterprise/ag-grid/, zero to:"/docs/..." targets remain across all 509 compiled route files, and the footer emits https://reflex.dev/docs + path

Not fixed here (needs someone with deploy access)

Two things the audit found that are not fixable in this repo — details in the review comment below:

  • 6 documented pages 404 in production (/docs/components/{props,conditional-rendering,rendering-iterables,html-to-reflex}, /docs/assets/{overview,upload-and-download-files}) even though they register and compile correctly. They are linked from the sidebar of ~79 pages, listed in sitemap.xml, and advertised in llms.txt.
  • CSP blocks Google Analytics on every page: connect-src allows www.google-analytics.com but GA4 posts to analytics.google.com and stats.g.doubleclick.net.

🤖 Generated with Claude Code