Skip to content

fix(core): add twitter card meta tag to store pages - #3425

Merged
eduardoformiga merged 7 commits into
vtex:devfrom
evander-corebiz:fix/seo-twitter-meta-tag
Aug 10, 2026
Merged

eduardoformiga merged 7 commits into
vtex:devfrom
evander-corebiz:fix/seo-twitter-meta-tag

Conversation

@evander-corebiz

@evander-corebiz evander-corebiz commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

Improve social media sharing previews on Twitter/X by adding the missing twitter:card meta tag across store pages. Without it, shared links default to plain text previews; adding summary_large_image ensures rich media cards with prominent visual assets.

How it works?

We configured the twitter prop inside the <NextSeo/> component to automatically inject the <meta name="twitter:card" content="summary_large_image" /> tag into the HTML <head>.

Why is this meta tag important?

  • Enhanced Visual Engagement: Forces Twitter/X to render links as rich media cards with large images instead of basic, small text links, significantly increasing click-through rates (CTR).
  • Consistent Brand Control: Ensures shared store URLs (Home, PLP, PDP, Blog) reliably use the structured OpenGraph fallback assets (og:title, og:description, og:image) when shared on X.
  • SEO & Social Compliance: Aligns the store with modern social media platform standards and audit guidelines.

Additionally, we updated Cypress E2E tests (meta[name="twitter:card"]) to assert that the tag is rendered correctly during hydration.

How to test it?

  • Open any page in the store (Home, Category, Product Detail Page).
  • Inspect the <head> section of the HTML.
  • Verify that <meta name="twitter:card" content="summary_large_image"> exists.
  • Run Cypress E2E tests (pnpm test:e2e or your store's test command) and confirm the SEO suite passes.

Starters Deploy Preview

References

Checklist

  • PR title and commit messages follow the Conventional Commits specification
    • Available prefixes: feat, fix, chore, docs, style, refactor, ci and test
  • Added a label according to the PR goal - breaking change, bug, contributing, performance, documentation..
  • Committed the pnpm-lock.yaml file when there were changes to the packages
  • PR description

Summary by CodeRabbit

  • New Features
    • Added Twitter card metadata using the summary_large_image format across key pages.
    • Improved social sharing previews for home, product, collection, filtered collection, and search pages.

@evander-corebiz
evander-corebiz requested a review from a team as a code owner July 31, 2026 13:48
@evander-corebiz
evander-corebiz requested review from eduardoformiga and lucasfp13 and removed request for a team July 31, 2026 13:48
@codesandbox-ci

codesandbox-ci Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 686ff770-555f-4f90-98f7-a744f1257fc7

📥 Commits

Reviewing files that changed from the base of the PR and between b02a99c and 46002fb.

📒 Files selected for processing (2)
  • packages/core/cypress/integration/seo.test.js
  • packages/core/next-seo.config.ts

Walkthrough

The SEO configuration now defines a summary_large_image Twitter card. Cypress tests verify this metadata on five page types.

Changes

Twitter SEO metadata

Layer / File(s) Summary
Configure Twitter card metadata
packages/core/next-seo.config.ts
The SEO configuration specifies the summary_large_image Twitter card.
Validate page Twitter metadata
packages/core/cypress/integration/seo.test.js
Home, product, collection, filtered collection, and search page tests verify the twitter:card meta tag and value.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: eduardoformiga, lucasfp13, renatomaurovtex

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the addition of the Twitter card meta tag to store pages.
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 unit tests (beta)
  • Create PR with unit tests

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.

@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)
packages/core/cypress/integration/seo.test.js (1)

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

Extend coverage to every changed SEO path.

This test checks only pages.home, while the PR changes the landing page, product listing page, product page, and both search SEO branches. Add the same assertion to the existing product, collection, filtered collection, and search tests. Add a landing-page test when a landing fixture is available.

This prevents a route-specific Twitter metadata regression from passing CI.

Also applies to: 72-76

🤖 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 `@packages/core/cypress/integration/seo.test.js` at line 50, Extend the SEO
metadata assertions from the existing pages.home test to the product,
collection, filtered collection, and both search test paths, and add a
landing-page case when a landing fixture exists. Reuse the current
OpenGraph/Twitter assertion and each test’s existing route or fixture setup
without changing unrelated coverage.
🤖 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 `@packages/core/cypress/integration/seo.test.js`:
- Line 50: Extend the SEO metadata assertions from the existing pages.home test
to the product, collection, filtered collection, and both search test paths, and
add a landing-page case when a landing fixture exists. Reuse the current
OpenGraph/Twitter assertion and each test’s existing route or fixture setup
without changing unrelated coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 53ec5b8a-d0f3-4672-9635-89b26b1479f1

📥 Commits

Reviewing files that changed from the base of the PR and between adf842c and 806fb2c.

📒 Files selected for processing (7)
  • packages/core/cypress/integration/seo.test.js
  • packages/core/src/components/templates/LandingPage/LandingPage.tsx
  • packages/core/src/components/templates/ProductListingPage/ProductListingPage.tsx
  • packages/core/src/pages/[slug]/p.tsx
  • packages/core/src/pages/index.tsx
  • packages/core/src/pages/s.tsx
  • packages/ui/src/styles/base/utilities.scss

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

Thanks for the contribution! The goal is right — twitter:card is genuinely missing and summary_large_image with OG fallback is the correct choice. A few things before merge:

PR title

🟠 ⚡ [conventions] Scope metaTags will fail the "Lint PR" check

Actions haven't run yet on this PR (first-time contributor, workflows pending approval), but Lint PR validates the title against a fixed scope list (core|ui|api|components|sdk|lighthouse|diagnostics|deps|deps-dev) — metaTags isn't in it, so the check will fail as soon as workflows are approved. Rename to:

fix(core): add twitter card meta tag to store pages

Approach — packages/core/src/pages/_app.tsx already renders <DefaultSeo />

🟡 ⚡ [simplification] Set the twitter card once in next-seo.config.ts instead of 6 hardcoded copies

_app.tsx renders <DefaultSeo {...SEO} /> from packages/core/next-seo.config.ts. Adding the twitter config there applies it to every page (next-seo dedupes by key, so any page-level NextSeo that sets twitter still wins):

 const config: DefaultSeoProps = {
   norobots: storeConfig.experimental.noRobots,
   dangerouslySetAllPagesToNoFollow: storeConfig.experimental.nofollow,
   dangerouslySetAllPagesToNoIndex: storeConfig.experimental.noindex,
+  twitter: {
+    cardType: 'summary_large_image',
+  },
   additionalMetaTags: [

This replaces all six per-page additions and also covers the NextSeo pages this PR misses (404.tsx, 500.tsx, login.tsx, checkout.tsx, the pvt/account/* pages) plus any future page for free. As written, a link to a 404/login page shared on X still gets a plain-text preview.

packages/ui/src/styles/base/utilities.scss

🟡 ⚡ [hygiene] Unrelated whitespace reformat — does this need to be in this diff?

The include-media breakpoints re-indent has nothing to do with meta tags and touches a second published package (@faststore/ui) for a no-op. Looks like editor auto-format — please revert so the diff stays scoped to what the title says.

packages/core/cypress/integration/seo.test.js

🟡 [tests] Assertion only added to the Home suite

The PR changes PDP, PLP/collection and search pages too, and this file already has has OpenGraph tags tests for Product Page Seo, Collection Page Seo, Filtered Collection Page Seo and Search Page Seo. Add the same twitter:card assertion to those suites (it's the same 5 lines) — especially if you keep the per-page approach, since each page then has its own code path to regress.

💬 Forward-looking: at some point stores may want to override the card type (or set site/handle) via discovery.config SEO settings, like settings.seo already flows into title/description. Not needed now — the hardcoded default is sensible.


Verdict: Approved with comments

Blocking (🟠):

  • PR title scope metaTags → use fix(core): (Lint PR check will reject it once workflows are approved)

Non-blocking (🟡/💬):

  • Centralize in next-seo.config.ts via DefaultSeo instead of 6 per-page copies (also fixes the pages this PR misses)
  • Revert the unrelated utilities.scss reformat in @faststore/ui
  • Extend the twitter:card assertion to the PDP/Collection/Search Cypress suites
  • CMS/store-config override as a future follow-up

Checks to confirm before merge: workflows approved + Lint PR green · pnpm lint · build · Cypress SEO suite · pnpm size (touches core; drops to core-only if the ui scss change is reverted)

@evander-corebiz
evander-corebiz force-pushed the fix/seo-twitter-meta-tag branch 3 times, most recently from 3967b4c to 9c2439b Compare August 3, 2026 14:35
@evander-corebiz evander-corebiz changed the title fix(metaTags): add twitter meta tags to nextSeo fix(core): add twitter card meta tag to store pages Aug 3, 2026

@eduardoformiga eduardoformiga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for addressing the earlier feedback — title, next-seo.config.ts, Cypress coverage, and the unrelated SCSS cleanup all look good.

Nit: residual duplication

twitter.cardType: 'summary_large_image' is now correctly set once in next-seo.config.ts (via <DefaultSeo /> in _app.tsx), but the same block is still hardcoded on the page-level <NextSeo /> calls:

  • pages/index.tsx
  • pages/[slug]/p.tsx
  • pages/s.tsx (both branches)
  • LandingPage.tsx
  • ProductListingPage.tsx

Since the value is identical everywhere, the per-page copies are redundant — next-seo dedupes by meta key, so the HTML outcome is the same either way. Prefer keeping only the default config; that also covers pages this PR doesn't touch (404, login, checkout, etc.) without maintaining N copies.

Not blocking — happy to approve as-is if you'd rather ship and clean this up in a follow-up.

@sonar-workflows

Copy link
Copy Markdown

@eduardoformiga
eduardoformiga merged commit d439f66 into vtex:dev Aug 10, 2026
7 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.

3 participants