First
Returns the first item of an array. You can also use first with dot notation, also in the middle of a path.
Example
Data
json
{
"products": [
{
"title": "Hat",
"price": 10
},
{
"title": "Tee",
"price": 25.5
},
{
"title": "Cap",
"price": 8
}
]
}liquid
{% assign product = products | first %}
{{ product.title }}
{{ products.first.title }}Output
html
Hat
Hat