I know how to set the og:image for the store, but I want an og:image for each individual product. And I don’t want to use the featured image because it’s not 1200x628. I also don’t want to have to make all my product images 1200x628 just to get around this omission in the Shopify platform.
I can’t believe Shopify lets me set the meta title, meta description & alt tags on a per-product basis but not the og:image!
Well you could address that by creating a metafield as an image which can be configured with a different picture per product. You would then generate the the og:image tag in the product page based on that metafield.
The metafield only needs to be an image, you would then write a product condition inside theme.liquid that would conditionally display the default og:image if metafield entry is empty.
Could you explain a little more? I don’t want the og:image to display on the product page (it’s a different size than the other images), so how would I specify the image URL for each product?
I also have an og:image for the overall store that I want used when someone shares the home page.
When creating the metafield, add an image metafield to the product object, that way when you upload an image it will fetch its URL directly when you call it in the conditional code.
Our app can help you to change your social sharing image on each product, collection or page. We’re using metafields too but we provide an interface to do so.
After installing our app & code snippet, the code snippet will overwrite the existing social meta tags and you can set a custom preview image.