Skip to content

fix(blog): strip query string and hash from SEO canonical and JSON-LD URLs - #1645

Merged
aka-sacci-ccr merged 1 commit into
mainfrom
fix/blog-seo-canonical-strip-query-hash
Jul 16, 2026
Merged

fix(blog): strip query string and hash from SEO canonical and JSON-LD URLs#1645
aka-sacci-ccr merged 1 commit into
mainfrom
fix/blog-seo-canonical-strip-query-hash

Conversation

@aka-sacci-ccr

@aka-sacci-ccr aka-sacci-ccr commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

The blog SEO sections (blog/sections/Seo/SeoBlogPost.tsx and blog/sections/Seo/SeoBlogPostListing.tsx) build the page URL used for the <link rel="canonical">, the url/mainEntityOfPage of the BlogPosting/Blog JSON-LD nodes, and the BreadcrumbList items. A request arriving with ?utm_source=x, ?page=2 or a #hash leaked those into every emitted URL, producing dirty canonicals and JSON-LD URLs that vary between requests for the same page.

This happened in both paths: with canonicalBaseUrl configured (withCanonicalBase preserved search + hash) and without it (the request URL passed through untouched).

Fix

Normalize in withCanonicalBase (blog/utils/jsonLD.ts), which every emitted URL flows through: keep only origin + pathname, dropping query string and hash in both paths.

Preserved behavior:

  • relative canonicals are still resolved against req.url in the sections (no exceptions thrown);
  • without a base, relative URLs still pass through unchanged (guarded by URL.canParse);
  • the rest of the JSON-LD (readTime/aggregateRating guards, publisher, BreadcrumbList structure) is untouched.

Validation

  • deno check, deno fmt --check and deno lint pass on the helper and both sections (pre-commit hook also ran the repo-wide check).
  • deno eval assertions covering:
    • https://loja.com/blog/post?page=2#tophttps://loja.com/blog/post (no base)
    • https://loja.com/blog/post?page=2#top + base https://www.loja.com.brhttps://www.loja.com.br/blog/post
    • relative canonical /blog/dicas resolved against a req.url carrying ?utm_source=x, with and without base
    • relative URL without base passes through unchanged; clean absolute URLs are untouched

🤖 Generated with Claude Code


Summary by cubic

Strip query strings and hashes from blog SEO URLs so canonicals and JSON-LD stay clean and consistent across requests. Fixes noise from UTM params, pagination, and hash fragments.

  • Bug Fixes
    • Normalize all SEO URLs via withCanonicalBase to origin + pathname; works with or without a base.
    • Applies to <link rel="canonical">, JSON-LD url/mainEntityOfPage, and BreadcrumbList; relative URLs without a base pass through unchanged.

Written for commit 42a1476. Summary will update on new commits.

Review in cubic

… URLs

Requests arriving with ?utm_source=..., ?page=2 or a #hash were leaking
those into the canonical link, the BlogPosting/Blog url and
mainEntityOfPage, and the BreadcrumbList items emitted by SeoBlogPost
and SeoBlogPostListing. Normalize in withCanonicalBase so every emitted
URL is origin + pathname only, both with and without a configured
canonicalBaseUrl. Relative URLs without a base still pass through
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@aka-sacci-ccr, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 21 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 27264d3f-1753-4d25-ab11-3bd82946f157

📥 Commits

Reviewing files that changed from the base of the PR and between aae0ee6 and 42a1476.

📒 Files selected for processing (1)
  • blog/utils/jsonLD.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/blog-seo-canonical-strip-query-hash

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.159.7 update
  • 🎉 for Minor 0.160.0 update
  • 🚀 for Major 1.0.0 update

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@aka-sacci-ccr
aka-sacci-ccr merged commit a412c13 into main Jul 16, 2026
8 checks passed
@aka-sacci-ccr
aka-sacci-ccr deleted the fix/blog-seo-canonical-strip-query-hash branch July 16, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant