Skip to content

Stop linking released API pages to the unreleased /next tree - #5017

Merged
reakaleek merged 3 commits into
mainfrom
noindex-next-api-docs-8ba2820b
Nov 23, 2026
Merged

reakaleek merged 3 commits into
mainfrom
noindex-next-api-docs-8ba2820b

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Released API pages no longer link to the unreleased /next tree. The tree stays reachable at /api/<key>/next/ for anyone who opens that URL.

Affects: API reference

Prompt summary: The API docs show Next, the main branch of each spec. The team wants it hidden from search, the sitemap and indexing, and still available as a preview for developers who open the /next link by hand.

Why

Search, the sitemap and the robots meta already leave /next out, through #4972, #4979 and #4976. Two links still lead there. The version picker on every released page lists Next (unreleased), so readers and crawlers reach the preview in one click. The card on the API landing page opens /next when the default version fails to load.

What

Version picker

A released page lists only released versions. A /next page still lists Next (unreleased) as the selected entry, so the page says where the reader is and offers a way back. An API with main and one major, such as Logstash, shows no picker on its released pages, because one version is not a choice. The filter lives in ApiVersionSwitcher.Build, which feeds both menus and the breadcrumb.

API landing card

When the default version fails to load, the card opens the newest released version that did load. When only the unreleased tree loaded, the API has no card, and /api/llms.txt reads the same entry. The /next pages still render in that case.

Documentation

docs/data/openapi/api-explorer.md describes /next as a preview opened by its URL, and states the fallback of the card.

Out of scope: The .md, .json and .yaml files of the /next tree stay and carry no robots signal. A non-HTML file needs an X-Robots-Tag response header, which the CDN sets and this repository does not.

Verify

dotnet test --project tests/Elastic.ApiExplorer.Tests
# Build_ReleasedPage_ListsTheReleasedVersionsNewestFirstAndMarksCurrent — picker on a released page
# Build_MainAndOneMajor_ReleasedPageHasNoPicker — main plus one major
# Generate_VersionPickerKeepsTheSamePageWhenItExists — no rendered link to /next on a released page
# CatalogEntry_OnlyTheUnreleasedTreeLoads_HasNoCard — card fallback
mise run serve

Open /api/elasticsearch/ and /api/elasticsearch/next/ and compare the version picker.

Check on the preview

🤖 Generated with Claude Code

The `/next` tree is a preview that a developer opens by its URL. Search,
the sitemap and the robots meta already leave it out, but the version
picker on every released page and the fallback of the API landing card
still linked to it. The picker now lists `Next (unreleased)` only on
`/next` pages, and the card opens a released tree or is left out.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 23, 2026 18:42
@reakaleek
reakaleek requested a review from technige November 23, 2026 18:42
Comment on lines +518 to 519
if (CanonicalDocument(resolved) is not { } canonical)
return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

If /next is the only tree that renders in a build, omitting its card also suppresses the entire /api hub. The preview pages still link to /api in their breadcrumbs, so those links now lead to a missing page. Keep the hub available without the card, or omit its links when there is no hub.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change here. The hub goes missing only when every API in the build lost all of its released versions and main alone loaded. The build reports that state for each API, and the search export stops on it. A hub page with no cards gives the reader nothing to open, and a card for the preview is the link this PR removes. If a degraded build should still write an empty hub, that is a separate change to Generate, which skips the catalog page when it has no entries.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One distinction: the search-export failure does not itself prevent the preview pages from being generated. Generate renders products and then skips the catalog only when there are no entries; GenerateProduct renders each resolved tree before returning its (possibly null) catalog entry (OpenApiGenerator.cs#L135-L140, OpenApiGenerator.cs#L368-L420). The separate search-export path reports the unresolved versions and stops the export (OpenApiGenerator.cs#L226-L248); that diagnostic does not address the /api link still emitted on non-catalog pages (ApiBreadcrumbs.cs#L14-L24). So the concern still applies to the generated /next pages in this degraded case. If an empty hub is intentionally out of scope, omitting that breadcrumb when there is no hub remains the alternative in the finding.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right about the export: it stops the search index and does not stop the /next pages from rendering. I withdraw that part of my reply. The dead APIs crumb is real in that build.

I still leave it out of this PR, for two reasons.

The state needs every API in the build to declare a numeric major and to lose all of them while main loads. An API with no numeric major keeps main as its default tree, so IsNext is false and it keeps its card. The assembled site has several such APIs, so its hub cannot go missing this way. That leaves an isolated build of one versioned API whose index resolves and whose released specs all fail to fetch, and that build already reports each missing version.

Neither fix is local. ApiBreadcrumbs.Build does not know whether a hub exists, and the render context's catalog entries are empty in contexts that do have a hub, such as PageContentsAsync, so that list cannot stand in for it. Writing an empty hub means that Generate and GenerateCatalog stop skipping on zero entries, which also changes what a build with no loadable spec writes.

The right shape is one fact, whether the build writes a hub, that the catalog step and the breadcrumb both read. That is a change of its own.

@github-actions

Copy link
Copy Markdown
Contributor

reakaleek and others added 2 commits November 23, 2026 19:54
…view by @infra-vault-gh-plugin-prod)

An API with `main` and one major lost its version in the breadcrumb, the
browser title and the landing heading, because the picker list came back
empty. The list now keeps the one released entry. The menus still need
two entries to show.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…view by @infra-vault-gh-plugin-prod)

The fallback took the first released document in the order of the
version index. An index that lists `7` before `8` sent the card to `/v7`
when `9` failed to load. The fallback now picks the newest release that
loaded.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@reakaleek
reakaleek merged commit 35e3356 into main Nov 23, 2026
44 checks passed
@reakaleek
reakaleek deleted the noindex-next-api-docs-8ba2820b branch November 23, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant