How to Auto-Populate Blogs on Product and Collection Pages Based on Specific Tags

Hi,

I’m looking for some help with adding a section to our product and collection pages where we can feature related blog posts. The goal is to provide informative content for customers, not just to drive purchases but also to educate them on topics related. For example, if we have a collection of assistive technology products, we’d like to feature blogs about the benefits of using reader pens etc, and may include tips on how to create dyslexic-friendly classrooms which will relate to the use of assistive tech tools - you get the gist.

What I want to achieve is to auto-populate a section on the product and collection pages with blogs based on specific tags, rather than pulling from our entire blog collection. Specifically, I want the section to pull from URLs like /blogs/news/tagged/assistive-technology instead of /blogs/news.

At the moment, we can manually add blogs one by one into the section and include a button that directs to the relevant URL, but this process is very manual and time-consuming. We want to find a more dynamic solution to automate this.

I’ve looked through some similar queries in the Shopify Community but haven’t found any solutions that fit our exact needs. I’m fairly new to the technical side of things on Shopify, so any guidance or code suggestions would be greatly appreciated! Our theme is Xtra btw.

Thanks in advance!

Hi,

Create a New Snippet something related-blogs.liquid and add insert the example code

{% assign tags = product.tags %}
{% assign blog_posts = "" %}

{% for tag in tags %}
    {% assign tagged_posts = blogs.news.articles | where: "tags", tag %}
    {% if tagged_posts.size > 0 %}
        {% assign blog_posts = blog_posts | append: tagged_posts %}
    {% endif %}
{% endfor %}

{% if blog_posts.size > 0 %}
    
        ### Related Blog Posts
        
            {% for post in blog_posts %}
                - {{ post.title }}
                
            {% endfor %}
        

    

{% endif %}

Include snippet in product and collection Templates

Use CSS for styling