Open Graph and Twitter Card metadata module for Magento 2, Mage-OS, and Adobe Commerce storefronts.
mosaicora/module-opengraph gives product, category, CMS, and home pages the metadata that social platforms need to generate clean share previews. It works out of the box with sensible defaults, while still giving store teams per-store control over titles, descriptions, images, and generated social-preview image sizes.
- Adds Open Graph metadata across common storefront page types.
- Mirrors Open Graph values into optional Twitter Card tags.
- Lets admins choose title, description, and image sources without template changes.
- Supports custom Open Graph images for categories and CMS pages.
- Generates cached
1200x630social-preview images from local Magento media assets by default. - Provides an admin cache action for flushing generated Open Graph images.
The module resolves the active storefront context and applies metadata during layout generation.
- Product pages use the current product.
- Category pages use the current category on
catalog_category_view. - CMS pages use the active CMS page captured during render.
- The home page uses the current CMS home page when available, otherwise it falls back to the configured site name and default image.
- PHP
~8.1to~8.5 - Magento 2, Mage-OS, or Adobe Commerce with the Catalog, CMS, Store, Web API, and GraphQL modules enabled.
- Composer credentials for
repo.magento.comwhen installing Magento packages directly.
Install the package through Composer:
composer require mosaicora/module-opengraph:1.0.0Run the normal Magento upgrade and cache workflow:
bin/magento module:enable Mosaicora_OpenGraph
bin/magento setup:upgrade
bin/magento cache:flush config layout block_html eav full_page config_webserviceFor production-mode deployments, also regenerate dependency injection and static content according to the store's deployment process:
bin/magento setup:di:compile
bin/magento setup:static-content:deployInstall dependencies from the Magento project root. Do not run composer install inside a module directory mounted or symlinked into Magento because a nested vendor/ tree causes duplicate class loading during compilation.
The module adds a configuration section at:
Stores > Configuration > Mosaicora > Open Graph
Configuration is store-scoped where Magento allows it, so each store view can use its own site name, default image, metadata source attributes, and image optimization settings.
Enable Open Graph TagsSite NameDefault ImageEnable Twitter Card TagsTwitter Card Type
Serve Optimized OG ImageWidthHeightResize ModeBackground Color
Image optimization is enabled by default and uses 1200x630, the common Open Graph share-card aspect ratio. Local Magento media images can be converted into cached social-preview images. External image URLs are left unchanged.
- Product title, description, and image attribute sources.
- Category title and description attribute sources.
- CMS title and description field sources.
Individual products, categories, and CMS pages can also provide Open Graph-specific values when the module attributes or fields are available.
The module can output:
og:typeog:urlog:site_nameog:titleog:descriptionog:imageog:image:widthog:image:heighttwitter:cardtwitter:titletwitter:descriptiontwitter:image
Product pages may also output:
product:price:amountproduct:price:currencyproduct:availabilitywithinstockoroos
Twitter tags are copied from the resolved Open Graph values when Twitter Card output is enabled.
The module exposes anonymous read-only metadata endpoints intended for preview tooling and integrations:
GET /V1/mosaicora/opengraph/product/:skuGET /V1/mosaicora/opengraph/category/:categoryIdGET /V1/mosaicora/opengraph/cms/:identifierGET /V1/mosaicora/opengraph/home
These endpoints return the same resolved tags that frontend pages use. They do not expose private catalog data, but they are intentionally public.
Send Magento's standard Store request header to resolve metadata for a specific store view.
GraphQL exposes the same metadata on Magento's native storefront types:
ProductInterface.open_graphCategoryInterface.open_graphCmsPage.open_graphStoreConfig.home_open_graph
The tags field uses the same flexible name and content list returned by REST, including Open Graph, Twitter Card, and product metadata.
query ProductOpenGraph($sku: String!) {
products(filter: { sku: { eq: $sku } }) {
items {
sku
open_graph {
page_type
identifier
store_id
enabled
tags {
name
content
}
}
}
}
}query CategoryOpenGraph($uid: String!) {
categories(filters: { category_uid: { eq: $uid } }) {
items {
uid
open_graph {
enabled
tags {
name
content
}
}
}
}
}query PageOpenGraph($identifier: String!) {
cmsPage(identifier: $identifier) {
identifier
open_graph {
enabled
tags {
name
content
}
}
}
storeConfig {
home_open_graph {
enabled
tags {
name
content
}
}
}
}Disabled configuration returns enabled: false and an empty tags list. REST and GraphQL use the same normalized tag builders and storefront canonical URLs.
Out of the box, the module uses these fallbacks:
- Product title:
meta_title, thenname - Product description:
meta_description, thenshort_description, thendescription - Product image:
open_graph_image, thenimage, thensmall_image - Category title:
meta_title, thenname - Category description:
meta_description, thendescription - Category image:
image - CMS title:
meta_title, thentitle - CMS description:
meta_description, thencontent - Home page title: configured site name
- Home page image: configured default image
Text values are sanitized before output and truncated when needed.
Product images are resolved from the configured product image attribute and then through the default fallback list until a usable image is found.
Category images can use the category image automatically or a custom og_image_custom category attribute.
CMS pages can use the configured default image or a custom uploaded image stored in og_image_custom.
Only normalized paths under Magento media are used for local image optimization. Remote URLs are emitted unchanged and are never used for filesystem reads or generated cache files.
When image optimization is enabled, generated images are cached in:
pub/media/mosaicora/opengraph/cache
The cache key accounts for the source file, source modification time, target dimensions, and resize mode. Authorized admin users can clear generated Open Graph images from the Magento cache management screen.
The installation patches add these product attributes:
open_graph_imageog_title_modeog_title_attributeog_title_customog_description_modeog_description_attributeog_description_custom
The installation patches add these category attributes:
og_title_modeog_title_attributeog_title_customog_description_modeog_description_attributeog_description_customog_image_modeog_image_custom
CMS pages receive matching Open Graph fields through the admin UI component.
The module adds permissions for configuration access and generated image cache management:
Mosaicora_OpenGraph::configMosaicora_OpenGraph::flush_open_graph_images
When the module is mounted in Magento, run checks with the parent dependency tree:
vendor/bin/phpcs --standard=[module path]/Mosaicora_OpenGraph/phpcs.xml [module path]/Mosaicora_OpenGraph
vendor/bin/phpunit --configuration [module path]/Mosaicora_OpenGraph/phpunit.xml.distFor a standalone clone outside Magento, configure auth.json for repo.magento.com, run composer install, then use composer phpcs and composer test.
CI validates the package on PHP 8.1 and PHP 8.5. Pull requests from forks do not receive Magento repository credentials; maintainers rerun reviewed changes from a trusted repository branch.
GPL-3.0-or-later
Built and maintained by Mosaicora.io.
Mosaicora automatically creates stunning Open Graph images from your web pages using beautiful, customizable templates. No design tools or uploads needed.