How to add a blog section and filter by tags?

What my problem is:

I have a blog that is called Recipes and contains all recipes.

It contains blog posts with the tags pasta, rice, spinach.

The following should now appear on my /home:
Section 1: Blog that has only the blog posts tagged pasta.
Section 2: Blog that has only the blog posts tagged with rice
Section 3: Blog that has only the blog posts tagged with spinach

So I don’t want to show the complete blog content but only different categories.

Since different blog posts appear in multiple categories, I don’t want to duplicate the same blog posts multiple times and divide them into different blogs.

Hi @JanaVSC

You can choose the feature blog section 3 time on home page.

Can add the blogs posts accordingly.

Hi @JanaVSC

If you need this customization then contact me by mail for services.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail.
Contact info in signature.

Generally to do this in most themes you need 3 separate blogs.

Most themes do not check blog tags as part of the article display logic so need to be customized to do so.

It varies wildly among themes for how and where in the theme code to do such logic for a single tag.

Roughly you’d find the article loop for that section you’ve configured and use some liquid like the following to skip every article that doesn’t match the tag immediatly after the {% for … %} tag.

{% unless article.tags contains “tagname” %}{% continue %}{% endunless %}

https://shopify.dev/docs/api/liquid/objects/article#article-tags

That’s for one tag, to do it multiple times in the same section code you’d need to also create section settings so each section is configured with it’s own tag. So grossily the skip logic becomes

{% unless article.tags contains section.settings.tag %}{% continue %}{% endunless %}

https://shopify.dev/docs/themes/architecture/sections/section-schema

2 Likes

Sorry, I don’t think I’ve expressed myself in detail.

What my problem is:

I have a blog that is called Recipes and contains all recipes.

It contains blog posts with the tags pasta, rice, spinach.

The following should now appear on my /home:
Section 1: Blog that has only the blog posts tagged pasta.
Section 2: Blog that has only the blog posts tagged with rice
Section 3: Blog that has only the blog posts tagged with spinach

So I don’t want to show the complete blog content but only different categories.

Since different blog posts appear in multiple categories, I don’t want to duplicate the same blog posts multiple times and divide them into different blogs.

Thanks you!

How do I find out which liquid file I have to edit?