Home > Shopify Development > List all the posts on your site by tag

How to List all the posts on your site by tag on Shopify

Thomas Nguyen
Thomas Nguyen Updated: April 07, 2023


Drive 20-40% of your revenue with Avada
avada email marketing

So as to help your customers easily see all of your posts in different topics, you need to show all of your posts right on your website, along with their tags. It is really important for you to read carefully this instructional writing on How to list all your posts on your site by tag if you want to make this list on your own page.

List all your posts on your site by tag

Step 1: How to create a layout

Before taking an official step on adding the code to list your posts by tag on your website, you need to know How to create a layout that will show all your posts.

In _layouts directory, create a new file called home.html and add the following logic:

layout: default

{{ content }}
<ul class="myposts">
{% for post in site.posts %}
    <li><a href="{{ post.url }}">{{ post.title}}</a>
    <span class="postDate">{{ post.date | date: "%b %-d, %Y" }}</span>
{% endfor %}

Step 2: Create blog.md

Then, in your root directory, create a file called blog.md and specify the home layout:

title: Blog
layout: home

From that, contents of blog.md will be pushed into the {{ content }} tag in the home layout which will be pushed into the {{ content }} tag of the default layout.

Step 3: Generate post list

Now, just embark on adding the code to create a list of posts in multiple tags on your website.

If site.post directory helps you show all your posts in a list, site.tags file will allow you arrange your posts in different tags on your page. In this file, each item is an array with two elements. The first element in the array is the tag name, the second element is a list of the posts in that tag. Copy and paste this following code to site.tags directory:

{% for tag in site.tags %}
  <h2>{{ tag[0] }}</h2>
    {% for post in tag[1] %}
      <li><a href="{{ post.url }}">{{ post.title }}</a></li>
    {% endfor %}
{% endfor %}

Your setting up process is already done and your customers can see all your posts in multiple tags from now.


Your customers will find it uncomlicated when they are allowed to see all of your posts right on your website, especially in each tag. With some very basic steps above, we hope that this tutorial provides useful information in your web development process. Keep following us in next informative posts to get surprising things. Thank you for reading!

As the CTO of Avada, a company specializing in Marketing Automation Platform, I have over 10 years of experience in software development. I have successfully led Avada's technical team in creating innovative products for our clients.

Stay in the know

Get special offers on the latest news from AVADA.