[AEO] Clean page headlines in JSON-LD schema - #33509
pranavsekhar wants to merge 2 commits into
Conversation
Review
👉 Fix in your agent 👈Fix the following review findings in PR #33509 (https://github.com/cloudflare/cloudflare-docs/pull/33509).
Before making changes, review each finding and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g. the fix requires disproportionate effort for minimal benefit,
or the finding is factually incorrect), explain why
- If you need clarification before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
After triaging, follow this order:
1. Post a comment on this PR for any findings you are skipping, with the finding ID and your reasoning.
2. Then commit the fixes for the legitimate findings.
The comment must come before the commit — the bot reads PR comments when a new
push triggers a review, so skip comments posted after the push will be missed.
---
## Code Review
### Warnings (1)
#### CR-1dc86d7a5411 · Headline suffix stripping misses real separators
- **File:** `src/util/page-head.ts` line 14
- **Issue:** resolveBaseTitle only strips a " | " separator, but title overrides in the repo also use other separators. E.g. src/content/docs/use-cases/{ai,saas,apis,performance,...}/index.mdx have `title: Performance` with `head: - tag: title, content: Performance · Use cases`, and cloudflare-for-saas uses `content: Plans — Cloudflare for SaaS`. For these pages resolvePageHeadline returns "Performance · Use cases" / "Plans — Cloudflare for SaaS", keeping the section/product suffix the PR and the JSDoc on lines 36-37 promise to remove ("always the clean semantic page title without an SEO, product, or site suffix"). The clean frontmatter title is available as the `title` argument but is only used when there is no override.
- **Fix:** Make the headline derivation robust to the separators actually used in the repo's title overrides (" | ", " · ", " — ", " - "), or fall back to / prefer the frontmatter `title` (the semantic title) instead of parsing the `<title>` override, and add a test for the "Performance · Use cases" pattern.
Code ReviewThis code review is in beta and may not always be helpful — use your judgment. Warnings (1)
ConventionsNo convention issues found. Style Guide ReviewNo style-guide issues found. CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
|
/bonk will you review this finding and resolve it if accurate and appropriate: #33509 (comment) |
Verdict: Finding CR-1dc86d7a5411 is accurate, but only the second proposed fix is sound
Required change (working tree is read-only, so I can't apply it)This is a fork PR with a read-only working tree, so I can only describe the fix:
Note: the headline change would also give model pages |
|
@pranavsekhar mind fixing up this finding? |
|
Continuing this work on #33573 (its two commits are cherry-picked with credit to @pranavsekhar). Triage of CR-1dc86d7a5411 ("Headline suffix stripping misses real separators"):
Known tradeoff, noted in the PR body: pages whose override was richer than the H1 now get the bare frontmatter title (e.g. |
* fix: clean JSON-LD page headlines
* refactor: share clean title resolution
* fix: derive JSON-LD headline from the frontmatter title
Headline overrides use inconsistent separators (" - ", " — ", " · ") that
occur inside real page titles in both orders, so splitting them is not
reliable. The frontmatter title is the visible <h1>, which keeps the
structured-data headline consistent with the page content (addresses
CR-1dc86d7a5411 from the #33509 review).
* fix: guard the headline against title override leakage
resolvePageHeadline accepts the <title> override and documents it as
deliberately ignored, so the section/product suffix tests pass real
overrides and prove it is not parsed (addresses CR-669744c84224).
* fix: drop titleOverride from resolvePageHeadline
The override is no longer an input at all, so the headline being free of
override suffixes holds by construction and the call site is guarded by
TypeScript's excess-property check. Resolves the tension between
CR-7564e63faba3 (tests cannot prove ignoring) and CR-6f600c2b08b2 (dead
API surface): both findings dissolve with the param removed.
---------
Co-authored-by: pranavsekhar <pranavsekhar@cloudflare.com>
Summary
headlineinstead of the browser title with its product/site suffix.<title>and SEO title behavior.Before:
After:
Tests
pnpm exec vitest run src/util/page-head.node.test.tspnpm run checkpnpm run lintpnpm run format:core:checkDocumentation checklist