size

Filter = size

Returns the number of characters in a string or the number of items in an array.

INPUT

OUTPUT

{{ "Ground control to Major Tom." | size }}

28

INPUT

OUTPUT

{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} {{ my_array.size }}

4

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

Example

{% if site.pages.size > 10 %} This is a big website! {% endif %}