Home > Shopify Development > Link to related posts on a blog

How to link to related posts on a blog in Shopify

Sam Nguyen
Sam Updated: February 15, 2024

Share:

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

Looking for a way to link to related posts on a blog in Shopify? In this guide, we’ll show you how to easily add links to related posts, improving navigation and keeping visitors engaged. With these simple steps, you can enhance your blog’s user experience and SEO.

Step 1: Use the variable in the layout

Firstly, the admins can use the variable site.related_posts in the layout for the post. Then the ten most recent posts will be output by default. If the store owners are running Jekyll, admins can use the --lsi flag, the relevant posts will be scanned automatically.


...
<ul class="related_posts">
  {% for post in site.related_posts %}
    <li><a href="{{ post.url }}">{{ post.title }}</a></li>
  {% endfor %}
</ul>
...

Step 2: Add the limit

The users can choose numbers of related blogs posts will be shown by adding the limit in the layout.


...
<ul class="related_posts">
  {% for post in site.related_posts limit: 3 %}
    <li><a href="{{ post.url }}">{{ post.title }}</a></li>
  {% endfor %}
</ul>
...

Conclusion

Now that you know how to link to related posts on your Shopify blog, you can easily improve navigation and keep visitors engaged with relevant content. By following these simple steps, you’ll enhance both the user experience and SEO performance of your blog. Try adding related posts today to boost your blog’s effectiveness!


Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Singapore. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.

Stay in the know

Get special offers on the latest news from AVADA.