Skip to content

Paginate ​

Last updated View as Markdown

Splits a list into pages.

These lists can be paginated:

Inside the tag, the list holds the current page only, and the paginate object describes the pages.

liquid
{% paginate list by page_size %}
  {% for item in list %}
    forloop_content
  {% endfor %}
{% endpaginate %}
  • list: the list to paginate, for example collection.products.
  • page_size: the number of items per page, from 1 to 250. A number or a variable.

The page comes from the page query parameter, for example /collections/shoes?page=2.

Examples ​

Products of a collection ​

liquid
{% paginate collection.products by 24 %}
  {% for product in collection.products %}
    {% render 'product-card', product: product %}
  {% endfor %}

  {% for part in paginate.parts %}
    {% if part.is_link %}
      <a href="{{ part.url }}">{{ part.title }}</a>
    {% else %}
      <span>{{ part.title }}</span>
    {% endif %}
  {% endfor %}
{% endpaginate %}

Every product ​

liquid
{% paginate collections['all'].products by 24 %}
  {% for product in collections['all'].products %}
    {% render 'product-card', product: product %}
  {% endfor %}
{% endpaginate %}

Collections ​

liquid
{% paginate collections by 12 %}
  {% for collection in collections %}
    <a href="{{ collection.url }}">{{ collection.title }}</a>
  {% endfor %}
{% endpaginate %}

Deprecated form ​

The older form names a fixed list and an id, and exposes the page through items:

liquid
{% paginate collection.products by 24 cod, category_id: category.id %}
  {% for product in items %}
    forloop_content
  {% endfor %}
{% endpaginate %}

It still works, but new themes should use the form above. For search, use search.results. The older form also sets the paginate object. Its page parameter is page[<id>], for example page[cod]. Its other variables are listed on the same page.