Skip to content

Last ​

Returns the last item of an array. You can also use last 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 | last %}
{{ product.title }}
{{ products.last.title }}

Output

html
Cap
Cap