Repository navigation
fix(blocks): resolve a framework SEO section placed in page.sections - #652
Merged
Merged
Conversation
`commerce/sections/Seo/SeoPDPV2.tsx` (and the other `website`/`commerce`
SEO types) sat in SKIP_RESOLVE_TYPES, so SEO was derived from them only
under `page.seo`. On Deco for Fresh they were ordinary sections, and a
migrated decofile may carry one in `sections[]` with no `page.seo` at
all. The list dropped it, and the PDP shipped with no canonical, no
`og:url`, the site's default image and `og:type=website`.
`resolveDecoPage` now picks a framework SEO section out of the list and
resolves it as the page's SEO block when the page has no `seo`, after the
body so the loader they share (a named `PDP Loader`) is served from the
memo. It renders nothing and keeps its slot in the raw index. The
`ignoreStructuredData` toggle is honoured at the output for it, as on
Fresh — not as a fetch-skip, which would drop canonical and image for
humans; the site-wide `botAwareSeo` flag applies either way. `page.seo`
stays the primary source.
Also from SeoPDPV2's loader: `og:type=product` (which makes the Twitter
card `summary_large_image`), the 1200×1200 VTEX crop when
`optimizeImageForVTEX` is set, and `structuredDataControl` ("disable for
all" / "disable for users" / "always include") read the way
`commerce/utils/structuredData.ts` reads it.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
guitavano
approved these changes
Oct 9, 2026
|
🎉 This PR is included in version 7.77.9 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
commerce/sections/Seo/SeoPDPV2.tsx(andSeoPDP,SeoPLP,SeoPLPV2,website/sections/Seo/Seo*.tsx,deco-sites/std/sections/SEO.tsx) sit inSKIP_RESOLVE_TYPESinpackages/blocks/src/cms/resolve.ts, so the framework derives SEO from them only when they are underpage.seo. On Deco for Fresh they were ordinary sections, and a migrated decofile may carry one insidepage.sectionswith nopage.seoat all — the Oficina Reserva PDP block (pages-productpage-*.json) hasseo: nullandSeoPDPV2assections[0], withjsonLD: { __resolveType: "PDP Loader" },optimizeImageForVTEX: true,ignoreStructuredData: true,structuredDataControl: "disable for all".The list dropped it (
internalResolvereturnsnullfor the type), so every PDP shipped with no canonical, noog:url, the site's defaultog:image/twitter:image,og:type=websiteandtwitter:card=summary.Reproduction
Measured on deco-sites/oficina-tanstack (QA-163,
headdiff.mjsover 6 PDPs across 6 categories, prod × preview): production has<link rel="canonical">,og:url,og:image= the product's first image at-1200-1200,og:type=product,twitter:card=summary_large_image,twitter:image; the preview had none of them and the site default image instead. The site worked around it insrc/sdk/seo/pdp-seo.ts+ theProductDetailsloader insrc/setup/section-loaders.ts(contributing the same fields from the body section).Reference behaviour (deco-cx / Fresh)
commerce/sections/Seo/SeoPDPV2.tsx: loader derivestitle/description/image/canonical/noIndexing/jsonLDsfromjsonLD;optimizeImageForVTEX→optimizeVTEX({ width: 1200, height: 1200 }); renders<Seo {...props} type="product" />.website/components/Seo.tsx:twitter:card = type === "website" ? "summary" : "summary_large_image",og:type = type.commerce/utils/structuredData.ts:structuredDataControl ?? (ignoreStructuredData ? "disable for users" : "always include");"disable for all"never emits JSON-LD, metadata still comes from the data.Fix
resolveDecoPagepicks a framework SEO section out ofpage.sections(through Lazy/named-block/multivariate wrappers, viaresolveFinalSectionKey) and, when the page has noseo, resolves it withresolvePageSeoBlockafter the body, so the loader it shares with the body (the namedPDP Loader) is served from the request memo. It renders nothing and keeps its slot in the raw index (deferred sections are addressed by position,reExtractRawProps).page.seostays the primary source. Nothing changes for pages without such a section; elsewhere in the tree the types are still skipped.ignoreStructuredDatatoggle is honoured at the output for it (as on Fresh), not as a fetch-skip — a fetch-skip would also drop canonical/image/robots for humans. The site-widebotAwareSeoflag applies either way (resolvePageSeoBlockgets an opt-intoggleSkipsFetchparameter; default unchanged forpage.seo).deriveCommerceSeoFromJsonLD:og:type=productfor aProductDetailsPage(→twitter:card=summary_large_imageinbuildHead), the 1200×1200 VTEX crop whenoptimizeImageForVTEXis set, andstructuredDataControlread the way deco-cx reads it (top-level on PDP, underconfigJsonLDon PLP).Tests
packages/blocks/src/cms/resolve.test.ts: 11 new cases — SEO section in the list becomesseoSection(loader called once for a human, body keepsindex: 1), found under Lazy,page.seowins when both exist,botAwareSeostill skips the fetch;og:type=product,optimizeImageForVTEXcrop (and non-VTEX image left alone),structuredDataControlmodes on PDP and PLP.bun run --filter='./packages/blocks' test(Node 24): 920/920.typecheckgreen forblocks,tanstack,nextjs.packages/tanstacktests: 279/281 — the 2workerEntry.test.tsdraft-preview failures are pre-existing onmain.Found while validating deco-sites/oficina-tanstack#479.
🤖 Generated with Claude Code
Summary by cubic
Fixes framework SEO sections (like
commerce/sections/Seo/SeoPDPV2.tsx) placed directly inpage.sectionsbeing dropped during resolution, so migrated pages with nopage.seoshipped without a canonical URL,og:url, and product metadata.page.seois absent;page.seostays the primary source.ignoreStructuredDatanow only suppresses JSON-LD output, not the whole fetch, matching deco-cx; site-widebotAwareSeostill skips it for humans.deriveCommerceSeoFromJsonLDnow emitsog:type=productfor PDPs (which also setstwitter:card=summary_large_image), applies the 1200×1200 VTEX image crop whenoptimizeImageForVTEXis set, and readsstructuredDataControl("always include" / "disable for users" / "disable for all") the way deco-cx does.Written for commit 2174565. Summary will update on new commits.