Skip to content
SEO Extensions

Social Meta, Open Graph & Twitter Cards for Magento 2

Outputs Open Graph and Twitter Card tags on every Magento 2 storefront page, with product price, availability and brand tags on product pages, and removes Magento's own og: blocks so only one set is printed. No JavaScript.

  • Free
  • Themes listed: Hyvä + Luma
Free $0.00, in stock
Check requirementsSee the versions and themes listed for this package. Details Ask about setupInclude the package name and your Magento and PHP versions. Ask
$0.00
In stock
SKU
panth-social-meta
Links
composer require mage2kishan/module-social-meta
SKU
panth-social-meta
  • Package requirementsRead the source documentation
  • Developer profileView Upwork profile
  • Themes listedHyvä + Luma
  • PHP versions listed8.1, 8.2, 8.3, 8.4
  • Installation questionsDiscuss your store setup

What it does for your store

The main features, as listed in the module documentation.

  • Open Graph on every page

    og:title, og:description, og:image, og:url, og:type, og:site_name and og:locale on product, category, CMS and other pages.

  • Product tags

    Price in the store currency, currency, in stock or out of stock, and brand from the manufacturer attribute.

  • Twitter Cards

    Card, title, description, image and alt text that follow the Open Graph values, plus your site handle.

  • Image fallbacks

    og_image attribute, product or category image, a default image you upload, then the store logo.

  • One set of tags

    Removes the native opengraph blocks from the layout so the page does not print duplicates.

  • Per page overrides

    og_title, og_description and og_image fields on products and categories, per store view.

Installation

Example commands from the Magento root. Follow the package instructions and your staging and deployment process.

  1. 1Check the releaseMatch Magento, PHP, theme and dependency requirements.
  2. 2Install on stagingReview Composer changes and follow the package instructions.
  3. 3Configure and verifyUse the documented settings and test the affected features.
magento-root
$ composer require mage2kishan/module-social-meta
$ bin/magento setup:upgrade
$ bin/magento setup:di:compile
$ bin/magento setup:static-content:deploy -f
$ bin/magento cache:clean

Listed requirements

These are the details supplied in this listing. Confirm the selected release supports your Magento edition, PHP and storefront.

Magento versions listed2.4.6, 2.4.7, 2.4.8
PHP versions listed8.1, 8.2, 8.3, 8.4
Themes listedHyvä, Luma
Composer packagemage2kishan/module-social-meta

Read package requirements and license

Documentation

Product details and setup guidance. Check the package repository for release-specific instructions.

One set of social preview tags per page

Social Meta adds Open Graph and Twitter Card tags to the head of every Magento 2 storefront page. An observer removes Magento's own opengraph blocks from the layout, so only this module's og: tags reach the page. The tags come from two head blocks added through layout XML. There is no JavaScript, so the same output works on Hyvä and Luma without template changes.

What each page gets

  • Every page: og:type, og:title, og:description, og:image, og:url, og:site_name and og:locale.
  • Product pages: og:type product, product:price:amount with the final price in the store currency, product:price:currency, product:availability and product:brand from the manufacturer attribute.
  • Category, CMS and other pages: og:type website.
  • When an image is found: og:image:alt, and for files in the media folder the image width, height and type.
  • Twitter Card tags that follow the resolved Open Graph values. Pages without an image always use the summary card.

Where the values come from

Titles fall back from the og_title attribute to the meta title, the product or category name, the page title and finally the store name. Descriptions fall back from og_description to the meta description and then to the product, category or page text, with HTML removed and the result cut to 200 characters. Images fall back from og_image to the product or category image, the default image you upload, the store logo and the placeholder image. og:url drops the category path, query string and trailing slash.

Setup adds og_title, og_description and og_image to products and categories in the Search Engine Optimization section, so you can override any of them per store view.

Settings

Stores > Configuration > Panth Extensions > Social Meta has seven fields: Enable Open Graph Tags, Enable Twitter Card Tags, Twitter Card Type, Twitter Site Handle, Default OG Image, Enable Article Open Graph Tags and Article Registry Fallback. All of them can be set per website and store view. The og:locale value comes from the store locale setting.

Article pages

Content modules can supply article:published_time, article:modified_time, article:author and article:section through an extension point, with og:type article.

Caching

Both head blocks are cacheable, so the tags are stored in the full page cache with the rest of the page.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.4 to 2.4.8.
  • PHP 8.1 to 8.4.
  • mage2kishan/module-core, installed by Composer.
  • Hyvä or Luma storefront.

Free and open source under the MIT License.

Developer notes

  • Module Panth_SocialMeta, PHP namespace Panth\SocialMeta. It loads after Panth_Core, Magento_Catalog and Magento_Cms.
  • view/frontend/layout/default.xml adds panth_social_meta.opengraph and panth_social_meta.twittercard to head.additional. Each block uses a view model with isEnabled() and getTags().
  • Model\Social\OpenGraphResolver::resolve() and Model\Social\TwitterCardResolver::resolve() return property to content maps with empty values removed.
  • Article extension point: implement Panth\SocialMeta\Api\ArticleDataProviderInterface::getArticleData() and add the class to the providers argument of Panth\SocialMeta\Model\Social\Article\ArticleProviderPool in your module's di.xml. It must return a Panth\SocialMeta\Api\Data\ArticleDataInterface, and Model\Social\Article\ArticleData is the default implementation (published time, modified time, author, section, tags, og type). Providers are queried in order, the first result is used, and a provider that throws is skipped.
  • Article dates are normalised with strtotime() and printed in ISO 8601 format. The values from Api\Data\ArticleDataInterface::getTags() are not rendered.
  • The built-in provider under the key registry_fallback returns data only while Article Registry Fallback is on. Its registry keys can be changed through the registryKeys argument in di.xml.
  • Observer\Social\RemoveNativeOgObserver runs on the frontend event layout_generate_blocks_after. Blocks whose name starts with panth_social_meta. are never removed.
  • ACL resource Panth_SocialMeta::config. The module creates no database tables.
More information
Module Category SEO & Indexing
Best For All Sizes
Kishan Savaliya

Questions before you install?

Send me your composer.json and I will check for conflicts first. Free. Installation is +$45, custom work is quoted first.

Ask on WhatsApp