fix(seo): set og:type=product on product detail pages - #1635
Conversation
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>
Tagging OptionsShould a new tag be published when this PR is merged?
|
📝 WalkthroughWalkthroughAdds an optional ChangesSEO PDP description source and OG type
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
Replaced by #1636 — branch criada a partir da main sem o feat/seo-pdp-description-source. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
commerce/sections/Seo/SeoPDPV2.tsx (1)
54-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse the existing
stripHTMLutility instead of a custom regex.
website/components/Seo.tsxalready exports/uses astripHTMLhelper (applied to title/description in theComponentfunction). 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
stripHTMLis exported fromwebsite/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
📒 Files selected for processing (2)
commerce/sections/Seo/SeoPDPV2.tsxwebsite/components/Seo.tsx
Summary
"product"to theOGTypeunion inwebsite/components/Seo.tsxSeoPDPV2loader now explicitly returnstype: "product"so PDPs emit the correct Open Graph type instead of inheriting"website"from site configRoot cause
OGTypeonly had"website" | "article".SeoPDPV2spreadsctx.seoprops (which default totype: "website") without overriding the type, so every PDP rendered<meta property="og:type" content="website">.Test plan
?__decoFBT=0and inspectog:typein page source — should beproductSeoCategoryV2/SeoPLP)🤖 Generated with Claude Code
Summary by cubic
Set
og:type=producton product detail pages and add adescriptionSourceoption for meta descriptions to improve SEO and social previews.Product pages no longer inherit
og:type=website.Bug Fixes
"product"toOGTypeinwebsite/components/Seo.tsx.SeoPDPV2loader now setstype: "product"for PDPs.New Features
descriptionSourceprop ("seo" | "product") inSeoPDPV2.jsonLD.seo.descriptionandjsonLD.product.descriptionwhen needed.Written for commit d277ecc. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes