first

Filter = first

Returns the first item of an array.

INPUT

OUTPUT

{{ "Ground control to Major Tom." | split: " " | first }}

Ground

INPUT

OUTPUT

{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %} {{ my_array.first }}

zebra

You can use "first" with dot notation when you need to use the filter inside a tag:

Example

{% if my_array.first == "zebra" %} Here comes a zebra! {% endif %}