← Back to guides
TutorialLiquid · 2024-05-19

Shopify Liquid Loops: for, limit, offset & pagination

Master collection loops, block loops, and pagination—the patterns you will use on every theme.

The Basic for Loop

Loops repeat markup for each item in an array—products, cart lines, section blocks, or blog articles.

{% for product in collection.products %}
  <h2>{{ product.title }}</h2>
{% endfor %}

limit and offset

limit: 4 caps iterations. offset: 1 skips the first item—useful when the first product is featured elsewhere.

{% for product in collection.products limit: 4 offset: 1 %}
  {% render 'product-card', product: product %}
{% endfor %}

reversed

Add reversed to iterate last-to-first without changing your data source.

forloop helpers

forloop.index, forloop.first, and forloop.last help with numbering, active states, and dividers.

Pagination (Required at Scale)

Shopify stops unpaginated product loops at 50 items. Wrap collection and blog lists:

{% paginate collection.products by 24 %}
  {% for product in collection.products %}
    ...
  {% endfor %}
  {{ paginate | default_pagination }}
{% endpaginate %}

More snippets: Loops category on the cheat sheet.

Build faster with HTMLToLiquid Converter

Convert static HTML into dynamic Shopify sections.

Open converter