Skip to content

Derive page titles from product metadata - #4083

Open
theletterf wants to merge 3 commits into
mainfrom
feature/3938-product-title-fallback
Open

theletterf wants to merge 3 commits into
mainfrom
feature/3938-product-title-fallback

Conversation

@theletterf

@theletterf theletterf commented Sep 14, 2026

Copy link
Copy Markdown
Member

Pages keep their H1 as the visible heading while the HTML title automatically gains a product qualifier when inference resolves one product. API operation titles use the same fallback with an API qualifier.

Affects: Authoring, API reference

Prompt summary: Derive the page title from the H1 and append the product name from frontmatter automatically. Cover Pattern B and API operation pages without a manual title, while retaining the explicit override as a final fallback in the stacked PR. Reuse the merged product inference result and keep direct Pagefind records consistent with rendered metadata.

Why

Pages with concise H1 headings can omit the product context that search results need. Authors should not have to repeat deterministic product metadata in a separate title field, and API operation pages already have a configured product available during rendering.

What

Product-aware fallback

A Markdown page that resolves to exactly one product appends that product's display name when the H1 does not already contain it. Resolution merges page frontmatter with docset, repository, applies_to, and mapped_pages metadata. Pages with no product or multiple products keep the H1 unchanged because the builder cannot choose a single qualifier safely.

Search metadata

Browser, Open Graph, and HTML Pagefind metadata use the shared title resolver. The direct Pagefind exporter performs the same product inference for isolated static search records, so it cannot fall back to the unqualified H1.

API operation titles

API operation pages append the configured product name and the API keyword to their H1-derived title. Their visible heading and breadcrumb remain unchanged.

Public title suffix

Public assembler pages use the unified | Elastic Docs suffix. Isolated and custom-branded builds retain their existing site-specific suffixes.

Authoring guidance

The title syntax guide documents the automatic fallback, its inferred single-product boundary, and the API operation variant.

Verify

dotnet test tests/Elastic.Markdown.Tests/
dotnet test tests/Elastic.ApiExplorer.Tests/

Stack: 1 of 2. #4079 will stack on this PR.

Part of #3938.

@github-actions

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4083/

Sample changed pages:

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requesting changes: page title fallback was updated, but Pagefind title metadata still uses the raw H1 and can produce inconsistent search result titles.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • d31bhlox0wglh.cloudfront.net

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "d31bhlox0wglh.cloudfront.net"

See Network Configuration for more information.


What is this? | From workflow: PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

Comment thread src/Elastic.Markdown/Page/Index.cshtml

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved.


What is this? | From workflow: PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@theletterf
theletterf requested a review from Mpdreamz September 14, 2026 11:46

@Mpdreamz Mpdreamz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the product-aware title fallback work. I think this needs changes before merge:

  • P1 IndexViewModel.PageTitle checks only CurrentDocument.YamlFrontMatter?.Products when choosing the qualifier. Page rendering already computes inferred products in HtmlWriter through DocumentInferrerService.InferForMarkdown(...) and passes Products = pageProducts, so pages with one inferred product from docset config, repo, applies_to, or mapped_pages but no explicit frontmatter products will not get the product-aware title. This should reuse the page inference result instead of frontmatter-only products.

  • P2 PagefindMarkdownExporter still sets Meta["title"] to file.Title ?? url. Because the exporter creates Pagefind records directly, isolated static search can keep showing the unqualified title even though the rendered HTML meta tag changed.

I did not spot other issues in the title/API path.

@theletterf

Copy link
Copy Markdown
Member Author

Addressed both findings in 7ff0f696:

  • IndexViewModel.PageTitle now uses the merged inferred Products set rather than page frontmatter directly.
  • Rendered metadata and direct isolated Pagefind records now use the same PageTitleResolver; the exporter performs the same product inference before creating its record.
  • The title test now covers a product inherited from docset configuration with no page-level products: field.

The stacked #4079 also routes meta_title through the shared resolver and has been rebased.

@theletterf
theletterf requested a review from Mpdreamz September 14, 2026 15:55
theletterf and others added 3 commits September 15, 2026 14:24
Use a single declared product as the SEO qualifier while keeping the H1 as the visible title and the manual override available as a final fallback.

Co-Authored-By: GPT-5.6 Sol <noreply@anthropic.com>
Keep search result metadata consistent with the browser and Open Graph titles when product context is added automatically.

Co-Authored-By: GPT-5.6 Sol <noreply@anthropic.com>
Resolve titles once from merged product metadata so rendered pages and direct Pagefind records cannot diverge.

Co-Authored-By: GPT-5.6 Sol <noreply@anthropic.com>
@georgewallace

Copy link
Copy Markdown
Contributor

Please hold off on merging until I can fully test and verify this works as expected.

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.

3 participants