Skip to content

Conversation

@pedrobernardina
Copy link
Contributor

@pedrobernardina pedrobernardina commented Nov 14, 2025

Motivation

Previously, all OpenGraph (og:*) and Twitter meta tags implicitly inherited the global SEO values (title, description, image, canonical).
This caused two practical issues:

  1. No way to override OG/Twitter metadata per page, which is required for custom PLPs, hybrid routes, and cases where canonical and social URLs differ.

  2. og:url always reused the canonical URL, meaning pagination parameters like ?page leaked into OG metadata.
    Social platforms treat og:url as a cache key, which led to:

    • duplicated social previews
    • inconsistent sharing behavior
    • divergence from VTEX’s default behavior and SEO best practices

This PR introduces explicit override support for OG and Twitter configurations, restoring full control while remaining fully backward compatible.


✅ What’s Included

Added openGraphConfig and twitterConfig overrides

The following OG fields now support page-level overrides:

  • title
  • description
  • image
  • url

Summary by CodeRabbit

  • New Features
    • Added Open Graph configuration to customize title, description, image and optional URL (falls back to canonical when URL not provided).
    • Added Twitter configuration to customize title, description and image.
    • Social metadata now prefers explicit config values but falls back to existing metadata for predictable previews.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

Seo component now accepts optional openGraphConfig and twitterConfig; Open Graph and Twitter meta tags use those config values when present (falling back to existing title/description/image). og:url is emitted only if openGraphConfig.url or canonical exists, preferring openGraphConfig.url.

Changes

Cohort / File(s) Summary
SEO Metadata Configuration
website/components/Seo.tsx
Added optional openGraphConfig and twitterConfig to the exported Props; updated component parameter destructuring; meta tag generation now sources title/description/image from the respective configs when provided and falls back otherwise; og:url is emitted only if openGraphConfig.url or canonical exists, with openGraphConfig.url taking priority.

Sequence Diagram(s)

sequenceDiagram
  participant C as Seo Component
  participant L as Logic
  participant T as Twitter Meta
  participant O as OpenGraph Meta

  C->>L: props (title, description, image, canonical, openGraphConfig?, twitterConfig?)
  alt twitterConfig present
    L->>T: use twitterConfig.title/description/image
  else
    L->>T: use primary title/description/image
  end
  alt openGraphConfig present
    L->>O: use openGraphConfig.title/description/image
  else
    L->>O: use primary title/description/image
  end
  alt openGraphConfig.url exists
    L->>O: render og:url = openGraphConfig.url
  else if canonical exists
    L->>O: render og:url = canonical
  else
    L->>O: skip og:url
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Check fallback behavior for partially provided openGraphConfig / twitterConfig
  • Verify og:url precedence (openGraphConfig.url > canonical) and conditional emission
  • Ensure meta tags still render correctly when configs are absent

Possibly related PRs

Suggested reviewers

  • aka-sacci-ccr

Poem

🐰 Hop hop, the metadata now takes flight,
OpenGraph and Twitter tucked just right,
Fallbacks nibble clover through the night,
og:url hops to the config's sight,
A little rabbit cheers SEO delight.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The description covers motivation, practical issues, and what's included, but is missing required sections: Issue Link, Loom Video, and Demonstration Link from the template. Add the missing required sections: Issue Link (with #ISSUE_NUMBER), Loom Video (screencast link), and Demonstration Link (testable environment). These help reviewers understand and validate the changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding Twitter and OpenGraph configuration support to the SEO component, which is the primary purpose of this pull request.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 79ef339 and d844c64.

📒 Files selected for processing (1)
  • website/components/Seo.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • website/components/Seo.tsx

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 and usage tips.

@github-actions
Copy link
Contributor

Tagging Options

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

  • 👍 for Patch 0.132.3 update
  • 🎉 for Minor 0.133.0 update
  • 🚀 for Major 1.0.0 update

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
website/components/Seo.tsx (1)

43-56: Consider adding url to twitterConfig for consistency.

Twitter cards support a twitter:url meta tag, but twitterConfig only includes title, description, and image fields. While this may be intentional, it creates an asymmetry with openGraphConfig which does include a url field.

If you'd like to add it, apply this diff:

 /** @title Twitter Config */
 twitterConfig?: {
   title?: string;
   description?: string;
   image?: ImageWidget;
+  url?: string;
 };

Then update the Twitter meta tags section to use it:

+{twitterConfig?.url && <meta property="twitter:url" content={twitterConfig.url} />}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3808a3b and af06bbb.

📒 Files selected for processing (1)
  • website/components/Seo.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
website/components/Seo.tsx (1)
admin/widgets.ts (1)
  • ImageWidget (4-4)
🔇 Additional comments (2)
website/components/Seo.tsx (2)

72-73: LGTM!

Props destructuring correctly includes the new configuration objects.


107-109: Excellent solution to the og:url pagination issue!

The conditional rendering with priority given to openGraphConfig?.url over canonical directly addresses the pagination problem described in the PR objectives. This prevents query parameters from leaking into social media previews while maintaining backward compatibility.

@pedrobernardina pedrobernardina force-pushed the feat/og-and-twitter-seo-config branch from af06bbb to 79ef339 Compare November 14, 2025 11:55
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
website/components/Seo.tsx (1)

81-91: Avoid redundant sanitization by reusing sanitized variables.

The fallback chains re-sanitize t and desc when config values are absent, but lines 78-79 have already sanitized them into title and description. Reusing the sanitized variables would be more efficient and follow the DRY principle.

Apply this diff to eliminate duplicate sanitization:

-  const twitterTitle = stripHTML(twitterConfig?.title ?? t);
-  const twitterDescription = stripHTML(
-    twitterConfig?.description ?? desc ?? "",
-  );
+  const twitterTitle = twitterConfig?.title 
+    ? stripHTML(twitterConfig.title) 
+    : title;
+  const twitterDescription = twitterConfig?.description 
+    ? stripHTML(twitterConfig.description) 
+    : description;
   const twitterImage = twitterConfig?.image ?? image;
 
-  const openGraphTitle = stripHTML(openGraphConfig?.title ?? t);
-  const openGraphDescription = stripHTML(
-    openGraphConfig?.description ?? desc ?? "",
-  );
+  const openGraphTitle = openGraphConfig?.title 
+    ? stripHTML(openGraphConfig.title) 
+    : title;
+  const openGraphDescription = openGraphConfig?.description 
+    ? stripHTML(openGraphConfig.description) 
+    : description;
   const openGraphImage = openGraphConfig?.image ?? image;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af06bbb and 79ef339.

📒 Files selected for processing (1)
  • website/components/Seo.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
website/components/Seo.tsx (1)
admin/widgets.ts (1)
  • ImageWidget (4-4)
🔇 Additional comments (3)
website/components/Seo.tsx (3)

43-56: LGTM! Clean interface additions.

The new openGraphConfig and twitterConfig props are well-structured and maintain backward compatibility. The inclusion of url only in OpenGraph config aligns with the PR objective of fixing og:url behavior for pagination scenarios.


78-91: Past review feedback has been addressed.

The sanitization concerns raised in previous reviews have been resolved—stripHTML is now correctly applied to both twitterConfig and openGraphConfig values before rendering them in meta tags.


120-122: Well-implemented conditional og:url logic.

The conditional rendering of og:url correctly prioritizes openGraphConfig.url over canonical, which addresses the core PR objective of preventing pagination parameters from leaking into OpenGraph metadata.

@pedrobernardina pedrobernardina force-pushed the feat/og-and-twitter-seo-config branch from 79ef339 to d844c64 Compare November 14, 2025 12:00
@aka-sacci-ccr aka-sacci-ccr merged commit d8a22db into deco-cx:main Nov 14, 2025
3 checks passed
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.

2 participants