Twig Filters

Herbie is using Twig Filters for modifying variables in layout and content files. In addition to the built-in filters of Twig itself, the following filters are available.


Returns file size in a human readable format (B, KB, MB, GB, TB, PB).

Parameter Type Description Default
[return] string The file size in human readable format
{{ 12345678|filesize }}


Find items of a traversable list by one or more selectors. Selectors are simple strings of text that specify fields and values. They are logical AND-connected and given as variadic arguments. Selectors in Herbie are loosely based around the idea and syntax of CSS attribute selectors. A selector can be one of the following:

=Equal to
!=Not equal to
<Less than
>Greater than
<=Less than or equal to
>=Greater than or equal to
*=Contains phrase/text
~=Contains all words
^=Starts with phrase/text
$=Ends with phrase/text
&Bitwise AND
Parameter Type Description Default
selectors string One or more selectors (optional, variadic)
[return] iterable The items matching the given selectors
{{ site.pageList|find("title^=this", "title~=is", "title$=great") }}


Returns a string slug for using as an URL segment.

Parameter Type Description Default
[return] string The slugified string
{{ "A string with spaces, Umlauts or special characters (?!&#)."|slugify }}


Formats a local time/date according to locale settings. This is a wrapper for the same-named PHP function.

Parameter Type Description Default
format string The format, see %x
[return] string The formatted time or date
{{ "2022-09-13"|strftime("%Y-%m-%d") }}


Filters the page tree by visible and active page items.

Parameter Type Description Default
[return] pageTree The filtered page tree
{{ site.pageTree|visible }}