How to use for break limit in Shopify

Since 2006, Liquid has been used in Shopify as a language template. In Liquid, you use tags consisting of comment, control flow, iteration, raw and variable to show complex content. In this tutorial, we will introduce you about some types of liquid iteration including for, break and limit.

Table of content

Brief guide to Liquid

There are three types in Liquid codes including objects, tags and filters. Liquid use objects to show the location of the content on a page. Double curly braces denote objects and variable names. Filters change a Liquid object’s output. Tags create logic and control flow for a template. Tags begin with two curly braces and percent signs. Tags can be divided into three types: control flow, iteration and variable assignment.

Iteration consists of several typical types that can help you display information on your front page. Today tutorial focuses on for, break and limit iteration.

General information about Liquid iteration

Iteration tags run blocks of codes repeatedly. For tag repeatedly executes a block of code.

How to use for break limit iteration

First of all, for tag repeatedly execute a block of code for a full list of attributes available within a for loop.


 {% for product in collection.products %}
    {{ product.title }}
  {% endfor %}


hat shirt pants

Second, break iteration causes the loop to stop iterating once it encounters this tag.


{% for i in (1..5) %}
  {% if i == 4 %}
    {% break %}
  {% else %}
    {{ i }}
  {% endif %}
{% endfor %}


1 2 3

Third, limit iteration limits the loop to the specified number of iterations. For instance, you have a chain of number and you want to show only two numbers of that chain on your website, then you should do:


<!-- if array = [1,2,3,4,5,6] -->
{% for item in array limit:2 %}
  {{ item }}
{% endfor %}


1 2


In conclusion, Liquid provides three iteration tags to you to execute blocks of codes. You can use tags of for, break and limit in order to upload the chain of characters. We hope that the tutorial is helpful, and let us know your difficulties, we will address them.

Recommend for you
Image Description
SEO Suite [FREE]

Auto-optimize website elements and structure in one-click.

Learn more
Proofo - Social Proof [FREE]

Use Social proof to boost sales

Learn more
Image Description
Size Chart [FREE]

Stunning size guide for great shopping experience

Learn more
Image Description
Free Shipping Bar [FREE]

Increase customers’ shopping cart size with free shipping offer

Learn more

Comments for Liquid Iteration: for break limit


Stay in the know

Get special offers on the latest news from AVADA.

40k subscribers has been joined!

Earn $10 in reward now!

go up