Group Blog posts by tag on Blog home page

Highlighted
Shopify Partner
7 0 1
Tag 1
Post
Post
Post

Tag 2
Post
Post
Post

Tag3 
Post

I want to group my blog posts by tag when you get to the blog landing page. Something like the above. Is this possible? I've tried a bunch of examples after searching hte forums, nothing is working. 

 

 

0 Likes
Highlighted
Shopify Partner
7 0 1

Hi Frans, 

I'm a developer working on a site, just trying to sort through the different code examples I've found in the forums to create a setup like this. Any help would be much appreciated. 

0 Likes
Highlighted
Shopify Partner
1 0 0

Could you not just sort articles into containers based on what their tag is? e.g.:
 

  <div class="articles-tag1">
    {% for article in blogs['my-blog'].articles %}
      {% for tag in article.tags %}
        {% if tag == "tag1" %}
          <div class="article">
            <h2>{{ article.title }}</h2>
          </div>
        {% endif %}
      {% endfor %}
    {% endfor %}
  </div>

  <div class="articles-tag2">
    {% for article in blogs['my-blog'].articles %}
      {% for tag in article.tags %}
        {% if tag == "tag2" %}
          <div class="article">
            <h2>{{ article.title }}</h2>
          </div>
        {% endif %}
      {% endfor %}
    {% endfor %}
  </div>

  <div class="articles-tag3">
    {% for article in blogs['my-blog'].articles %}
      {% for tag in article.tags %}
        {% if tag == "tag3" %}
          <div class="article">
            <h2>{{ article.title }}</h2>
          </div>
        {% endif %}
      {% endfor %}
    {% endfor %}
  </div>

 

0 Likes
Highlighted
New Member
1 0 0

I've read on several post on this forum that it's shopify framework problem.

It was working at some point but stopped working. 

Shopify support needs to make something about it.

0 Likes
Highlighted
New Member
2 0 0
 {% for tag in blogs['FAQs'].all_tags %}
              {% assign t = tag %}
                  {% for article in blogs['FAQs'].articles %}
              {% for tag in article.tags %}
                      {% if tag == t %}
                          {{ article.title }} {{t}}<br>
                      {% endif %}
              {% endfor %}
                {% endfor %}
              {% endfor %}
0 Likes
Highlighted
New Member
1 0 0

 

 


@Lucerov wrote:
 {% for tag in blogs['FAQs'].all_tags %}
              {% assign t = tag %}
                  {% for article in blogs['FAQs'].articles %}
              {% for tag in article.tags %}
                      {% if tag == t %}
                          {{ article.title }} {{t}}<br>
                      {% endif %}
              {% endfor %}
                {% endfor %}
              {% endfor %}

Where is this code supposed to be inserted?

0 Likes
Highlighted
Shopify Expert
142 0 28

Its better to do it like this:

 

{%- assign blog = blogs['your-blog-handle'] -%}
{% paginate blog.articles by 500 %}
{% for article in blog.articles %}
{%- if article.tags contains 'tag 1' -%}
{{ article.title }}
{%- endif -%}
{% endfor %}
{% endpaginate %}
0 Likes