Skip to content

fix(blocks): resolve a framework SEO section placed in page.sections - #652

Merged
guitavano merged 1 commit into
mainfrom
fix/seo-section-in-sections-array
Oct 9, 2026
Merged

guitavano merged 1 commit into
mainfrom
fix/seo-section-in-sections-array

Conversation

@aline-pereira

@aline-pereira aline-pereira commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

commerce/sections/Seo/SeoPDPV2.tsx (and SeoPDP, SeoPLP, SeoPLPV2, website/sections/Seo/Seo*.tsx, deco-sites/std/sections/SEO.tsx) sit in SKIP_RESOLVE_TYPES in packages/blocks/src/cms/resolve.ts, so the framework derives SEO from them only when they are under page.seo. On Deco for Fresh they were ordinary sections, and a migrated decofile may carry one inside page.sections with no page.seo at all — the Oficina Reserva PDP block (pages-productpage-*.json) has seo: null and SeoPDPV2 as sections[0], with jsonLD: { __resolveType: "PDP Loader" }, optimizeImageForVTEX: true, ignoreStructuredData: true, structuredDataControl: "disable for all".

The list dropped it (internalResolve returns null for the type), so every PDP shipped with no canonical, no og:url, the site's default og:image/twitter:image, og:type=website and twitter:card=summary.

Reproduction

Measured on deco-sites/oficina-tanstack (QA-163, headdiff.mjs over 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 in src/sdk/seo/pdp-seo.ts + the ProductDetails loader in src/setup/section-loaders.ts (contributing the same fields from the body section).

Reference behaviour (deco-cx / Fresh)

  • commerce/sections/Seo/SeoPDPV2.tsx: loader derives title/description/image/canonical/noIndexing/jsonLDs from jsonLD; 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

  • resolveDecoPage picks a framework SEO section out of page.sections (through Lazy/named-block/multivariate wrappers, via resolveFinalSectionKey) and, when the page has no seo, resolves it with resolvePageSeoBlock after the body, so the loader it shares with the body (the named PDP 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.seo stays the primary source. Nothing changes for pages without such a section; elsewhere in the tree the types are still skipped.
  • The ignoreStructuredData toggle 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-wide botAwareSeo flag applies either way (resolvePageSeoBlock gets an opt-in toggleSkipsFetch parameter; default unchanged for page.seo).
  • deriveCommerceSeoFromJsonLD: og:type=product for a ProductDetailsPage (→ twitter:card=summary_large_image in buildHead), the 1200×1200 VTEX crop when optimizeImageForVTEX is set, and structuredDataControl read the way deco-cx reads it (top-level on PDP, under configJsonLD on PLP).

Tests

  • packages/blocks/src/cms/resolve.test.ts: 11 new cases — SEO section in the list becomes seoSection (loader called once for a human, body keeps index: 1), found under Lazy, page.seo wins when both exist, botAwareSeo still skips the fetch; og:type=product, optimizeImageForVTEX crop (and non-VTEX image left alone), structuredDataControl modes on PDP and PLP.
  • bun run --filter='./packages/blocks' test (Node 24): 920/920. typecheck green for blocks, tanstack, nextjs. packages/tanstack tests: 279/281 — the 2 workerEntry.test.ts draft-preview failures are pre-existing on main.

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 in page.sections being dropped during resolution, so migrated pages with no page.seo shipped without a canonical URL, og:url, and product metadata.

  • Picks such a section out of the list and resolves it as the page's SEO block after the body when page.seo is absent; page.seo stays the primary source.
  • ignoreStructuredData now only suppresses JSON-LD output, not the whole fetch, matching deco-cx; site-wide botAwareSeo still skips it for humans.
  • deriveCommerceSeoFromJsonLD now emits og:type=product for PDPs (which also sets twitter:card=summary_large_image), applies the 1200×1200 VTEX image crop when optimizeImageForVTEX is set, and reads structuredDataControl ("always include" / "disable for users" / "disable for all") the way deco-cx does.

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

View guided diff Turn on auto-fix

`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]>
@aline-pereira
aline-pereira requested a review from a team October 9, 2026 00:31
@guitavano
guitavano merged commit 4c354cf into main Oct 9, 2026
1 check passed
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 7.77.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants