Skip to content

fix(seo): set og:type=product on product detail pages - #1635

Closed
igoramf wants to merge 2 commits into
mainfrom
fix/og-type-product
Closed

fix(seo): set og:type=product on product detail pages#1635
igoramf wants to merge 2 commits into
mainfrom
fix/og-type-product

Conversation

@igoramf

@igoramf igoramf commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds "product" to the OGType union in website/components/Seo.tsx
  • SeoPDPV2 loader now explicitly returns type: "product" so PDPs emit the correct Open Graph type instead of inheriting "website" from site config

Root cause

OGType only had "website" | "article". SeoPDPV2 spreads ctx.seo props (which default to type: "website") without overriding the type, so every PDP rendered <meta property="og:type" content="website">.

Test plan

  • Load a PDP with ?__decoFBT=0 and inspect og:type in page source — should be product
  • Home/category pages unaffected (still use SeoCategoryV2 / SeoPLP)

🤖 Generated with Claude Code


Summary by cubic

Set og:type=product on product detail pages and add a descriptionSource option for meta descriptions to improve SEO and social previews.
Product pages no longer inherit og:type=website.

  • Bug Fixes

    • Added "product" to OGType in website/components/Seo.tsx.
    • SeoPDPV2 loader now sets type: "product" for PDPs.
  • New Features

    • descriptionSource prop ("seo" | "product") in SeoPDPV2.
    • Strips HTML from product descriptions and falls back between jsonLD.seo.description and jsonLD.product.description when needed.

Written for commit d277ecc. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Product pages now support product-specific SEO metadata, including a product Open Graph type.
    • Meta descriptions can now use either SEO or product content when no custom description is set.
  • Bug Fixes

    • Improved how page descriptions are generated by normalizing product text before use.
    • Updated social sharing metadata so product pages display the correct preview format.

igoramf and others added 2 commits June 30, 2026 14:31
Adds a `descriptionSource` prop ("seo" | "product") that controls which
field is used as the meta description when no manual override is set.

- "seo" (default): uses jsonLD.seo.description — existing behavior, no breaking change
- "product": strips HTML from jsonLD.product.description — useful when
  the SEO description is empty or when the richer product copy is preferred

In VTEX, product.description is a rich-text HTML field meant for page
display, while seo.description maps to metaTagDescription — a plain-text
field designed for meta tags. The "product" source strips HTML before
writing to <meta name="description"> and og:description.

Falls back to the other source if the chosen one is empty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SeoPDPV2 was inheriting og:type from site-level config (usually "website").
Adds "product" to OGType union and explicitly sets type="product" in the
SeoPDPV2 loader so PDPs emit the correct Open Graph type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Tagging Options

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

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

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an optional descriptionSource prop to SeoPDPV2 controlling whether the page meta description is derived from SEO jsonLD data or from the product's own description (HTML-stripped), sets the returned SEO type to "product", and extends the OGType union in Seo.tsx to accept "product".

Changes

SEO PDP description source and OG type

Layer / File(s) Summary
descriptionSource prop and resolution logic
commerce/sections/Seo/SeoPDPV2.tsx
Adds descriptionSource?: "seo" | "product" to Props, computes a cleaned product description, updates the resolvedDescription fallback chain accordingly, and sets returned SEO type to "product".
OGType union extension
website/components/Seo.tsx
Extends OGType to include "product", so the component emits og:type="product" and selects the summary_large_image Twitter card for that type.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • deco-cx/apps#1474: Both PRs modify website/components/Seo.tsx's Open Graph/Twitter meta-tag handling.

Suggested reviewers: aka-sacci-ccr

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, root cause, and testing, but it omits the required issue link, Loom video, and demonstration link sections. Add the missing template sections with an issue link, a Loom walkthrough, and a demo/preview link, and keep the required headings.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: setting og:type to product on PDPs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/og-type-product

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.

@igoramf

igoramf commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Replaced by #1636 — branch criada a partir da main sem o feat/seo-pdp-description-source.

@igoramf igoramf closed this Jul 3, 2026

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
commerce/sections/Seo/SeoPDPV2.tsx (1)

54-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse the existing stripHTML utility instead of a custom regex.

website/components/Seo.tsx already exports/uses a stripHTML helper (applied to title/description in the Component function). This loader reimplements HTML stripping with a raw regex (/<[^>]+>/g), which duplicates logic and may diverge in edge-case handling (e.g., malformed tags, entities) from the canonical implementation used elsewhere in the same SEO pipeline.

♻️ Suggested reuse
-  const productDescription = jsonLD?.product.description
-    ?.replace(/<[^>]+>/g, " ")
-    .replace(/\s+/g, " ")
-    .trim();
+  const productDescription = jsonLD?.product.description
+    ? stripHTML(jsonLD.product.description).replace(/\s+/g, " ").trim()
+    : undefined;

Please confirm stripHTML is exported from website/components/Seo.tsx (or the appropriate shared module) before applying.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@commerce/sections/Seo/SeoPDPV2.tsx` around lines 54 - 63, The SEO PDP loader
is duplicating HTML stripping with an inline regex in the product description
flow. Replace the custom replacement in SeoPDPV2 with the shared stripHTML
helper used by the Seo component, and import it from website/components/Seo.tsx
or its shared module after confirming it is exported. Keep the
resolvedDescription logic the same, but ensure productDescription is normalized
through the canonical utility instead of bespoke regex handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@commerce/sections/Seo/SeoPDPV2.tsx`:
- Around line 54-63: The SEO PDP loader is duplicating HTML stripping with an
inline regex in the product description flow. Replace the custom replacement in
SeoPDPV2 with the shared stripHTML helper used by the Seo component, and import
it from website/components/Seo.tsx or its shared module after confirming it is
exported. Keep the resolvedDescription logic the same, but ensure
productDescription is normalized through the canonical utility instead of
bespoke regex handling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b56d6b31-d4c8-430c-aa2e-dbca91ab49f5

📥 Commits

Reviewing files that changed from the base of the PR and between b562530 and d277ecc.

📒 Files selected for processing (2)
  • commerce/sections/Seo/SeoPDPV2.tsx
  • website/components/Seo.tsx

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