Link product & blog posts by blog post metafield

Topic summary

Goal: Show on product pages the blog posts (recipes) that reference those products, using a blog article metafield of type Product List (a metafield is a custom data field; Product List stores product references).

Constraints: 500+ articles require a reverse lookup (product → articles). Shopify lacks an article/blog reference metafield type, and Shopify Flow can’t trigger on new articles.

Approaches considered:

  • Liquid (Shopify’s templating language) nested loops over all articles and each article’s product-list metafield to find matches; possible but likely too slow at this scale.
  • Put related article handles in a product metafield (e.g., list of strings) and render server-side via articles[ā€˜blog-handle/article-handle’]; efficient at render time but creates manual upkeep whenever new posts are published.
  • Build automation/app to sync: watch for new articles and copy relationships into product metafields; could be a private Rails app or a no‑code workflow with Make. Hiring a Shopify Expert is also suggested.

Current direction: Moving toward a custom/private app to leverage existing blog metafield data while avoiding manual updates.

Open questions: Whether a GraphQL (API query language) query can fetch articles by a product referenced in a metafield (potentially for Mechanic or a custom app) remains unanswered. A brief Liquid snippet was shared for article-by-handle access.

Summarized with AI on January 24. AI used: gpt-5.

Hello, each of our 500+ blog posts has a metafield for related products. The metafield type is a Product List.

I want to use this blog post metafield data to be able to show the blog posts on the page for their related products.

Is there a way to do this?

  1. Loop through all blog articles and check the metafield?
  2. Query blog posts somehow in a Liquid template?
  3. Create own app?

Hey, @spicemerchant

This does sound like custom app territory as I haven’t come across an existing app that does this. I’m confident one of our Shopify experts would be able to accomplish this at a reasonable price.

Just wanted to share this as an option in case you are unable to find a coding solution in your thread.

If there is anything else I can help you with, please let me know.

Thanks for the fast reply, Dirk!

Is there a GraphQL query to get blog posts by product in a metafield? If so I might be able to do this with Mechanic.

Or with my own app… I’m a rails and js developer as well. Just need a good starting point.

So, what you want to do is suggest related blog articles in product pages right?

There is a way to loop over all blog articles in your product page, and then for each blog article loop over the product list metafields to see if there is a match. The main issue with this approach is that it is a nested loop startegy, knowing that you have 500+ articles… There is a trick to achieve this using pagination (not tried for awhile but I think this can work) ; but to be frank, this is taking the problem from the wrong end, and is not a great idea for performance.

Since what you need to modify is the product page, could you not add a metafield in your product page instead of blog page? This metafield would be a list of related blog articles for your product.

Shopify is known for doing some things halfway, and I have no idea why there is not a blog or article reference available in metafields. So until this becomes a thing, you could still create a metafields of type ā€œsingle line texteā€ with ā€œlist of valuesā€ option. And for each product, you would add the articles ā€œhandleā€ that you want.

You can access a blog article in product page by its handle like this (here I’m assuming there is only one blog):

{%- assign article = articles['blog-handle/article-handle'] -%} 
{{ article.title }}

Of course this code snippet would need to be adjusted to retrieve the article handles from the product metafield, but you get the idea.

Thanks Max. I’ve considered that, but we don’t want the work flow of updating multiple products’ metafields every time we have a new blog post. The management will be unwieldy.

I think we’ll need to make a custom app. The data already exists in Shopify so it’s a matter of getting it out.

You will still need to figure out how you render the blog post articles in your product pages. If you want the blog articles to be rendered server-side, using product metafields seems like a good approach (as I explained above).

I guess your app could be watching for when new articles are created, and create/migrate metafields data to the product metafield. By the way this can be done in a quick fashion using a ā€œno-codeā€ tool such as Make (Shopify Flow does not support yet watching for new articles).

1 Like

I might try that! Right now, if I could get the Rails private app working… this app itself will be really straightforward. :slightly_smiling_face:

Just curious, what kind of related blog posts are you showing on the product pages? Is that a way of driving traffic to the blog posts, or are they specifically relevant to those products? Sounds pretty cool.

We have recipes featuring food products, so want the product pages to link to the specific recipes that use them, without creating extra work to go link/unlink outside of setting the product list metafield on the recipe. Thanks!

Anyone knows the point of the blog post metafield under products? I added a metafield for blog posts, selected blog posts per product, but the theme editor does not show ā€œblog postsā€ as an option in dynamic sourcing.