Skip to content
Log in

Paginate - Liquid Tag Reference

On this page

The paginate block tag wraps a PaginatedList collection so it actually fetches and returns results, in pages of a given size. Certain Liquid globals (for example pricebook_entries on current_pricebook) return a PaginatedList rather than a plain array, and require this wrapping to yield any items at all.

Syntax

```liquid

{% paginate collection by page_size %} {% for item in collection %} {% endfor %} {% endpaginate %} ```

Property Value
Tag Name paginate
Type Block tag
Source Hydrofoil (core)
Arguments collection — the PaginatedList to page through. page_size — the number of items to return per page (after by).

Description

paginate takes a PaginatedList and a page size, and makes that many items available to a loop inside the block. Loop over the same collection name you passed to paginate; there is no separate .items accessor to unwrap:

```liquid

{%- paginate current_pricebook.pricebook_entries by 20 -%} {%- for entry in current_pricebook.pricebook_entries -%} {%- assign product = entry.product -%} {{ product.name }} {%- endfor -%} {%- endpaginate -%} ```

:::warning A PaginatedList does not lazily fetch results on its own. A plain {% for %} loop over one, without wrapping it in paginate, silently returns zero items rather than raising an error. Always wrap the loop in {% paginate collection by page_size %} ... {% endpaginate %} first. :::

For an example that queries and paginates a store’s full product catalog, see Build structured data feeds for AI answer engines. For collections returned by the query tag, see Liquid query tag reference.

Was this article helpful?

Was this article helpful?