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
composer require mage2kishan/module-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.
- 1Check the releaseMatch Magento, PHP, theme and dependency requirements.
- 2Install on stagingReview Composer changes and follow the package instructions.
- 3Configure and verifyUse the documented settings and test the affected features.
$ 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 listed | 2.4.6, 2.4.7, 2.4.8 |
|---|---|
| PHP versions listed | 8.1, 8.2, 8.3, 8.4 |
| Themes listed | Hyvä, Luma |
| Composer package | mage2kishan/module-social-meta |
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 namespacePanth\SocialMeta. It loads afterPanth_Core,Magento_CatalogandMagento_Cms. view/frontend/layout/default.xmladdspanth_social_meta.opengraphandpanth_social_meta.twittercardtohead.additional. Each block uses a view model withisEnabled()andgetTags().Model\Social\OpenGraphResolver::resolve()andModel\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 theprovidersargument ofPanth\SocialMeta\Model\Social\Article\ArticleProviderPoolin your module'sdi.xml. It must return aPanth\SocialMeta\Api\Data\ArticleDataInterface, andModel\Social\Article\ArticleDatais 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 fromApi\Data\ArticleDataInterface::getTags()are not rendered. - The built-in provider under the key
registry_fallbackreturns data only while Article Registry Fallback is on. Its registry keys can be changed through theregistryKeysargument indi.xml. Observer\Social\RemoveNativeOgObserverruns on the frontend eventlayout_generate_blocks_after. Blocks whose name starts withpanth_social_meta.are never removed.- ACL resource
Panth_SocialMeta::config. The module creates no database tables.
| Module Category | SEO & Indexing |
|---|---|
| Best For | All Sizes |
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.