Skip to content
Log in

group_by - Liquid Filter Reference

On this page

Description

Groups an list of objects by a given property

Property Value
Return Type list
Category collections

Examples

liquid {% assign list = products | group_by: "type" %} {% for group in list %}({{ group.name }}){% for item in group.items %}[{{ item.name }}]{% endfor %}{% endfor %}

Output: (whitegoods)[Fridgetastic 3000][Coldinator 500](computers)[Geronimo 9000][Y2K Amaze]

liquid {% assign list = products | group_by: grouping_field %} {% for group in list %}({{ group.name }}){% for item in group.items %}[{{ item.name }}]{% endfor %}{% endfor %}

Output: (whitegoods)[Fridgetastic 3000][Coldinator 500](computers)[Geronimo 9000][Y2K Amaze]

Was this article helpful?

Was this article helpful?