Built-in filters
We will list the most useful filters here. You can find the complete list of filters in the official Liquid documentation.
append
Read the complete append documentation.
Adds the specified string to the end of another string.
{{"/my/fancy/url" | append: ".html"}}/my/fancy/url.htmldate
Read the complete date documentation.
Converts a timestamp into another date format. The format for this syntax is the same as strftime. The input uses the same format as Ruby’s Time.parse.
{{article.published_at | date: "%a, %b %d, %y"}}Fri, Jul 17, 22{{article.published_at | date: "%Y"}}2022date works on strings if they contain well-formatted dates
{{"March 14, 2022" | date: "%b %d, %y"}}Mar 14, 22To get the current time, pass the special word "now" (or "today") to date.
Last update: {{"now" | date: "%Y-%m-%d %H:%M"}}Last update: 2022-03-14 12:34default
Read the complete default documentation.
Sets a default value for any variable with no assigned value. default will show its value if the input is nil, false, or empty.
In this example, product_price is not defined, so the default value is used.
{{product_price | default: 2.99}}2.99In this example, product_price is defined, so the default value is not used.
{% assign product_price = 4.99 %}
{{product_price | default: 2.99}}4.99In this example, product_price is empty, so the default value is used.
{% assign product_price = "" %}
{{product_price | default: 2.99}}2.99divided_by
Read the complete divided_by documentation.
Divides a number by another number.
{{16 | divided_by: 4}}
{{5 | divided_by: 3}}4
1minus
Read the complete minus documentation.
Subtracts a number from another number.
{{4 | minus: 2}}
{{16 | minus: 4}}
{{183.357 | minus: 12}}2
12
171.357newline_to_br
Read the complete newline_to_br documentation.
Inserts an HTML line break (<br />) in front of each newline () in a string.
{{"Hello\nWorld" | newline_to_br}}Hello<br />
Worldplus
Read the complete plus documentation.
Adds a number to another number.
{{4 | plus: 2}}
{{16 | plus: 4}}
{{183.357 | plus: 12}}6
20
195.357times
Read the complete times documentation.
Multiplies a number by another number.
{{3 | times: 2}}
{{24 | times: 7}}
{{183.357 | times: 12}}6
168
2200.284where
Read the complete where documentation.
Creates an array including only the objects with a given property value, or any truthy value by default.
In this example, assume you have a list of products and you want to show your kitchen products separately. Using where, you can create an array containing only the products that have a "type" of "kitchen".
All products:
{% for product in products %}
- {{ product.title }}
{% endfor %}
{% assign kitchen_products = products | where: "type", "kitchen" %}
Kitchen products:
{% for product in kitchen_products %}
- {{ product.title }}
{% endfor %}All products:
- Vacuum
- Spatula
- Television
- Garlic press
Kitchen products:
- Spatula
- Garlic pressLast updated
Was this helpful?
