Add related products to your blog posts using Metafields in Shopify.

Stephen Keable
3 min readOct 18, 2022

Like my article about linking products to other products using metafields in Shopify, this short article shows that we can use a similar approach to link to products from a blog post too.

We can make use of the same product reference metafields definition, this time against the blog posts instead of products.

Creating the definition

Head to the Settings -> Metafields section of your store admin. Here we can select the “Blog posts” part of the store to add a field to.

Then we can add a new definition.

Here we use the name “Related Products” and key “custom.related_products” which will work in the liquid snippet below.

Select the “Product reference” content type. Followed by the “List of products” if you want to be able to link multiple products from your blog post.

Once saved it will appear at the foot of a page when editing a blog post (You might need to click the “See all” link in the metafields panel first). Here you can select some products and change the order too.

Displaying the related products

Now we need to add some liquid to your page template via editing the code (If you’re unsure how always hire a developer to do edit code for you) or as a “Custom liquid” block in the theme customiser.

Couple of related photo prints at the foot of an article

This liquid snippet should be a good starting place for you or your developer.

{%- if article.metafields.custom.related_products.value -%}
{%- assign…

--

--

Stephen Keable

Shopify partner, JavaScript/Liquid/Swift developer, convert to serverless architecture and builder of digital products people love to use since 1999.