Skip to content

Uniq ​

Last updated View as Markdown

Use uniq to remove the duplicate items from an array. When the input is nil, you get an empty array.

Example ​

Data
json
{
  "colors": [
    "red",
    "blue",
    "red"
  ]
}
liquid
{{ colors | uniq | join: ', ' }}

Output

html
red, blue

Property ​

You can give a property name. Then only the first item with each value of that property is kept.

liquid
{{ products | uniq: 'type' | map: 'title' | join: ', ' }}