Skip to main content

How do I display the tags of each blog post with the excerpt on the main blog page?

Official response from

Using Liquid, we can loop through each of the most recent blog posts, and, for each blog post, loop through each of its tags to display them. Here's how:

In the template of your main blog page, you'll see a Liquid "for loop" that iterates through each of the recent blog posts:

{% for post in page.blog.most_recent_blog_posts %}

... code to display each blog's excerpt ...

{% endfor %}

Within this loop, we need to make another loop that iterates through the tags of each post, and then to output each tag:

{% for post in page.blog.most_recent_blog_posts %}

... blog excerpt display code ...

{% if post.tags_count > 0 %}
    <div class="page-tags">
        <div class="padbottom">
            <i class="icon-tag"></i>
            <div class="page-tag-background">
                {% for tag in post.tags %}
                    <span class="page-tag" data-id="{{ tag.id }}"><a href="{{ tag.url }}">{{ tag.name }}</a></span>
                {% endfor %}
            </div>
        </div>
    </div>
{% endif %}

{% endfor %}

The example here also includes wrappers and classes that mirror those of the default Aware theme styling for tags, but feel free to change those up to suit your own custom themes.

Share this post

Showing 11 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.