Skip to content

Give every API page a meta description built from spec facts - #5013

Merged
reakaleek merged 8 commits into
mainfrom
api-explorer-seo-pages-91b4b004
Nov 23, 2026
Merged

reakaleek merged 8 commits into
mainfrom
api-explorer-seo-pages-91b4b004

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

API landing, group, operation, authentication and servers pages that have no description of their own now get a one-sentence meta description built from facts the spec declares. Text from the spec or an authored page still wins.

Affects: API reference

Prompt summary: Fill the missing meta descriptions on API group, authentication, servers and landing pages for the SEO work in docs-eng-team#949. Where neither the spec nor an authored page has text, use a template that names only facts the spec declares, so no page claims more than the spec does.

Why

The SEO crawl found API pages with no meta description. The layout omits the tag when the description is empty, so a search engine shows its own excerpt. #4762 filled the pages that have source text. The Servers pages, Authentication pages without a topic, and any group or operation with no text still have none.

Closes elastic/docs-eng-team#1180

What

One rule for the fallback

ApiFallbackDescription.For takes the page and returns the sentence. It runs only when the spec or authored text gives nothing. The HTML pages and the Markdown front matter both call it, so the two cannot disagree.

The sentences

  • Landing: Reference documentation for the {product} API.
  • Group: {group} endpoints in the {product} API: {first four operation titles}.
  • Operation: {title}: {METHOD} {route} in the {product} API.
  • Authentication: How to authenticate requests to the {product} API: {scheme names}., or The {product} API declares no authentication for the API as a whole. when no document-level scheme exists
  • Servers: Server URLs for the {product} API: {URLs}.

Every sentence is cut at or before 150 characters, ellipsis included.

Shared helper

ApiTag.OverviewRows replaces three copies of the same BuildTagChildren call.

Verify

dotnet test --project tests/Elastic.ApiExplorer.Tests
# Generate_PagesWithNoSourceSentence_GetADescriptionBuiltFromSpecFacts — no page is empty, exact text for the bare group, operation, servers and authentication pages, HTML and Markdown agree

Removing the fallback in ApiViewModel.CreateGlobalLayoutModel makes that test fail.

Out of scope: Catalog, schema and topic pages still emit an empty description when they have no text. They are not in the issue title. To list pages that remain empty on a real build, run this against the output folder:

grep -L 'name="description"' $(find .artifacts/docs/html/docs/api -name index.html)

🤖 Generated with Claude Code

…page a meta description

A page whose spec and authored text say nothing now takes a one-sentence description built from facts the spec declares: the product name, the method and route, the group's operation titles, the auth scheme names or the server URLs. `ApiFallbackDescription.For` is the one place that decides, so the HTML pages and the Markdown front matter cannot disagree. Text from the spec or the authored page still wins.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 23, 2026 16:34
@reakaleek
reakaleek requested a review from akira28 November 23, 2026 16:34
@github-actions

Copy link
Copy Markdown
Contributor

reakaleek and others added 4 commits November 23, 2026 21:32
…@infra-vault-gh-plugin-prod)

A long route or URL could push a fallback past the limit, because `ApiSeoDescription.Truncate` looks for a space after the cutoff. `ApiFallbackDescription.For` now cuts at or before the limit, ellipsis included.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…none (per review by @infra-vault-gh-plugin-prod)

A spec that allows only anonymous access produced "How to authenticate requests", while the page says it declares no schemes.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…TML comment (per review by @infra-vault-gh-plugin-prod)

The HTML page drops the comment and uses the generated sentence. The Markdown front matter kept the comment as its description.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ption (per review by @infra-vault-gh-plugin-prod)

Every landing in the existing test owned or inherited a description, so deleting the landing fallback left it green.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
reakaleek and others added 3 commits November 23, 2026 21:39
…view by @infra-vault-gh-plugin-prod)

A character such as an emoji in a title or product name could straddle the 150-character cut and leave half a pair, which encodes as a replacement character. `Cap` backs up one unit in that case.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…review by @infra-vault-gh-plugin-prod)

No document-level scheme does not mean no scheme: a spec can allow anonymous access overall and still declare an API key on single operations. The sentence now claims only the document level.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ents (per review by @infra-vault-gh-plugin-prod)

A description that opened with an HTML comment and then had prose got the generated sentence in Markdown, while the HTML page used the prose. Both now drop comments before they pick the first line.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@reakaleek
reakaleek merged commit 5c2cfca into main Nov 23, 2026
44 checks passed
@reakaleek
reakaleek deleted the api-explorer-seo-pages-91b4b004 branch November 23, 2026 20:55
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