Exporteo Help
Search…
Liquid filters
Filters are simple methods that modify the output of numbers, strings, variables and objects. They are placed within an output tag {{ }} and are denoted by a pipe character |.
Input
1
<!-- item.title = "Invisible Watch" -->
2
{{ item.title | upcase }}
Copied!
Output
1
INVISIBLE WATCH
Copied!
In the example above, item is the object, title is its attribute, and upcase is the filter being applied.
Some filters require a parameter to be passed.
Input
1
{{ item.title | remove: "Invisible" }}
Copied!
Output
1
Watch
Copied!
Multiple filters can be used on one output. They are applied from left to right.
Input
1
<!-- item.title = "Invisible Watch" -->
2
{{ item.title | upcase | remove: "INVISIBLE" }}
Copied!
Output
1
WATCH
Copied!

Array filters

Array filters change the output of arrays. Array is a synonym to list. For example, order.line_items is an array of line items or order.transactions is an array of transactions.

join

Joins the elements of an array with the character passed as the parameter. The result is a single string.
Input
1
{{ product.tags | join: ', ' }}
Copied!
Output
1
tag1, tag2, tag3
Copied!

first

Returns the first element of an array.
Input
1
<!-- product.tags = "sale", "mens", "womens", "awesome" -->
2
{{ product.tags | first }}
Copied!
Output
1
sale
Copied!
You can use first with dot notation when you need to use the filter inside a tag.
1
{% if product.tags.first == "sale" %}
2
This product is on sale!
3
{% endif %}
Copied!

last

Returns the last element of an array.
Input
1
<!-- product.tags = "sale", "mens", "womens", "awesome" -->
2
{{ product.tags | last }}
Copied!
Output
1
awesome
Copied!
You can use last with dot notation when you need to use the filter inside a tag.
1
{% if product.tags.last == "sale"%}
2
This product is on sale!
3
{% endif %}
Copied!
Using last on a string returns the last character in the string.
Input
1
<!-- product.title = "Awesome Shoes" -->
2
{{ product.title | last }}
Copied!
Output
1
s
Copied!

concat

Concatenates (combines) an array with another array. The resulting array contains all the elements of the original arrays. concat will not remove duplicate entries from the concatenated array unless you also use the uniq filter.
Input
1
{% assign fruits = "apples, oranges, peaches, tomatoes" | split: ", " %}
2
{% assign vegetables = "broccoli, carrots, lettuce, tomatoes" | split: ", " %}
3
4
{% assign plants = fruits | concat: vegetables %}
5
6
{{ plants | join: ", " }}
Copied!
Output
1
apples, oranges, peaches, tomatoes, broccoli, carrots, lettuce, tomatoes
Copied!
You can string together multiple concat filters to combine more than two arrays:
Input
1
{% assign fruits = "apples, oranges, peaches" | split: ", " %}
2
{% assign vegetables = "broccoli, carrots, lettuce" | split: ", " %}
3
{% assign animals = "dogs, cats, birds" | split: ", " %}
4
5
{% assign things = fruits | concat: vegetables | concat: animals %}
6
7
{{ things | join: ", " }}
Copied!
Output
1
apples, oranges, peaches, broccoli, carrots, lettuce, dogs, cats, birds
Copied!

index

Returns the item at the specified index location in an array. Note that array numbering starts from zero, so the first item in an array is referenced with [0].
Input
1
<!-- product.tags = "sale", "mens", "womens", "awesome" -->
2
{{ product.tags[2] }}
Copied!
Output
1
womens
Copied!

map

Accepts an array element's attribute as a parameter and creates an array out of each array element's value.
Input
1
<!-- collection.title = "Spring", "Summer", "Fall", "Winter" -->
2
{% assign collection_titles = collections | map: 'title' %}
3
{{ collection_titles }}
Copied!
Output
1
SpringSummerFallWinter
Copied!

flat_map ⭐

Creates a flattened array of values taken from the specified attribute of each element of the input array.
Input
1
<!--
2
order = {
3
line_items: [{
4
discount_allocations: [{
5
amount: 1.23
6
}, {
7
amount: 2.34
8
}]
9
}, {
10
discount_allocations: [{
11
amount: 3.45
12
}]
13
}]
14
}
15
-->
16
{{ order.line_items | flat_map: "discount_allocations" | json }}
Copied!
Output
1
[{"amount":1.23},{"amount":2.34},{"amount":3.45}]
Copied!

group_by ⭐

Groups elements of the same property value. Creates an object where keys are the specified property value, and values are arrays of elements with the same property value.
Input
1
<!--
2
order = {
3
line_items: [{
4
price: 1.23,
5
vendor: "A"
6
}, {
7
price: 2.34,
8
vendor: "B"
9
}, {
10
price: 3.45,
11
vendor: "A"
12
}]
13
}
14
-->
15
{{ order.line_items | group_by: "vendor" | json }
Copied!
Output
1
{"A":[{"price":1.23,"vendor":"A"},{"price":3.45,"vendor":"A"}],"B":[{"price":2.34,"vendor":"B"}]}
Copied!

reverse

Reverses the order of the items in an array.
Input
1
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
2
3
{{ my_array | reverse | join: ", " }}
Copied!
Output
1
plums, peaches, oranges, apples
Copied!

size

Returns the size of a string (the number of characters) or an array (the number of elements).
Input
1
{{ 'The quick brown fox jumps over a lazy dog.' | size }}
Copied!
Output
1
42
Copied!
You can use size with dot notation when you need to use the filter inside a tag.
1
{% if collections.frontpage.products.size > 10 %}
2
There are more than 10 products in this collection!
3
{% endif %}
Copied!

sort

Sorts the elements of an array by a given attribute of an element in the array.
1
{% assign products = collection.products | sort: 'price' %}
2
{% for product in products %}
3
<h4>{{ product.title }}</h4>
4
{% endfor %}
Copied!
The order of the sorted array is case-sensitive.
Input
1
<!-- products = "a", "b", "A", "B" -->
2
{% assign products = collection.products | sort: 'title' %}
3
{% for product in products %}
4
{{ product.title }}
5
{% endfor %}
Copied!
Output
1
A B a b
Copied!

where

Creates an array including only the objects with a given property value, or any truthy value by default.
Input
1
All products:
2
{% for product in collection.products %}
3
- {{ product.title }}
4
{% endfor %}
5
6
{% assign kitchen_products = collection.products | where: "type", "kitchen" %}
7
8
Kitchen products:
9
{% for product in kitchen_products %}
10
- {{ product.title }}
11
{% endfor %}
Copied!
Output
1
All products:
2
- Vacuum
3
- Spatula
4
- Television
5
- Garlic press
6
7
Kitchen products:
8
- Spatula
9
- Garlic press
Copied!
You can use a property name with where that has no target value when that property is a boolean or truthy. For example, the available property of products.
Example
1
{% assign available_products = collection.products | where: "available" %}
2
3
Available products:
4
{% for product in available_products %}
5
- {{ product.title }}
6
{% endfor %}
Copied!

uniq

Removes any duplicate instances of elements in an array.
Input
1
{% assign fruits = "orange apple banana apple orange" %}
2
{{ fruits | split: ' ' | uniq | join: ' ' }}
Copied!
Output
1
orange apple banana
Copied!

Date filter

date

Converts a timestamp into a specified date format.
format
description
example value
%d
Two-digit day of the month (with leading zeros)
01 to 31
%m
Two digit representation of the month
01 to 12
%y
Two digit representation of the year
21
%Y
Four digit representation for the year
2021
%H
Two digit representation of the hour in 24-hour format
00 to 23
%I
Two digit representation of the hour in 12-hour format
01 to 12
%p
Upper-case 'AM' or 'PM' based on the given time
AM or PM
%P
Lower-case 'am' or 'pm' based on the given time
am or pm
%M
Two digit representation of the minute
00 to 59
%S
Two digit representation of the second
00 to 59
%s
Unix Epoch Time timestamp
1612328167
Input
1
{{ order.created_at | date: "%Y-%m-%d %H:%M:%S" }}
Copied!
Output
1
2021-02-03 04:56:07
Copied!

Math filters

Math filters allow you to apply mathematical tasks.
Math filters can be linked and, as with any other filters, are applied in order of left to right. In the example below, minus is applied first, then times, and finally divided_by.Copy
1
You save {{ product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price }}%
Copied!

abs

Returns the absolute value of a number.
Input
1
{{ -25 | abs }}
Copied!
Output
1
25
Copied!
abs will also work on a string if the string only contains a number.
Input
1
{{ "-19.86" | abs }}
Copied!
Output
1
19.86
Copied!

at_most

Limits a number to a maximum value.
Input
1
{{ 4 | at_most: 5 }}
2
{{ 4 | at_most: 3 }}
Copied!
Output
1
4
2
3
Copied!

at_least

Limits a number to a minimum value.
Input
1
{{ 4 | at_least: 5 }}
2
{{ 4 | at_least: 3 }}
Copied!
Output
1
5
2
4
Copied!

ceil

Rounds an output up to the nearest integer.
Input
1
{{ 1.2 | ceil }}
2
{{ 3.0 | ceil }}
3
{{ 3.45 | ceil }}
Copied!
Output
1
2
2
3
3
4
Copied!
Liquid tries to convert the input to a number before the filter is applied.
Input
1
{{ "4.5" | ceil }}
Copied!
Output
1
5
Copied!

divided_by

Divides an output by a number. The output is rounded down to the nearest integer.
Input
1
<!-- product.price = 200 -->
2
{{ product.price | divided_by: 10 }}
Copied!
Output
1
20
Copied!

floor

Rounds an output down to the nearest integer.
Input
1
{{ 4.6 | floor }}
2
{{ 4.3 | floor }}
Copied!
Output
1
4
2
4
Copied!

minus

Subtracts a number from an output.
Input
1
<!-- product.price = 200 -->
2
{{ product.price | minus: 15 }}
Copied!
Output
1
185
Copied!

modulo

Divides an output by a number and returns the remainder.
Input
1
{{ 12 | modulo: 5 }}
Copied!
Output
1
2
Copied!

plus

Adds a number to an output.
Input
1
<!-- product.price = 200 -->
2
{{ product.price | plus: 15 }}
Copied!
Output
1
215
Copied!

round

Rounds the output to the nearest integer or specified number of decimals.
Input
1
{{ 4.6 | round }}
2
{{ 4.3 | round }}
3
{{ 4.5612 | round: 2 }}
Copied!
Output
1
5
2
4
3
4.56
Copied!

times

Multiplies an output by a number.
Input
1
<!-- product.price = 200 -->
2
{{ product.price | times: 1.15 }}
Copied!
Output
1
230
Copied!

to_fixed

Convert a number into a string, rounding the number to keep only the given number of decimals.
Input
1
{{ 1.2345 | to_fixed: 2 }}
Copied!
Output
1
1.23
Copied!
The difference between round and to_fixed it that round returns a number so it trims trailing zeros while to_fixed will preserve them.
Input
1
{{ 4.5000 | round: 2 }}
2
{{ 4.5000 | to_fixed: 2 }}
Copied!
Output
1
4.5
2
4.50
Copied!

String filters

String filters are used to manipulate outputs and variables of the string type.

append

Appends characters to a string.
Input
1
{% assign filename = "/index.html" %}
2
{{ "website.com" | append: filename }}
Copied!
Output
1
website.com/index.html
Copied!

capitalize

Capitalizes the first word in a string
Input
1
{{ "title" | capitalize }}
Copied!
Output
1
Title
Copied!

downcase

Converts a string into lowercase.
Input
1
{{ 'UPPERCASE' | downcase }}
Copied!
Output
1
uppercase
Copied!

escape

Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape.
Input
1
{{ "<p>test</p>" | escape }}
Copied!
Output
1
&lt;p&gt;test&lt;/p&gt;
Copied!

newline_to_br

Inserts a <br > linebreak HTML tag in front of each line break in a string.
Input
1
{% capture var %}
2
One
3
Two
4
Three
5
{% endcapture %}
6
{{ var | newline_to_br }}
Copied!
Output
1
<br />One<br />Two<br />Three<br />
Copied!

prepend

Adds the specified string to the beginning of another string.
Input
1
{{ 'sale' | prepend: 'Made a great ' }}
Copied!
Output
1
Made a great sale
Copied!

remove

Removes all occurrences of a substring from a string.
Input
1
{{ "Hello, world. Goodbye, world." | remove: "world" }}
Copied!
Output
1
Hello, . Goodbye, .
Copied!

remove_first

Removes only the first occurrence of a substring from a string.
Input
1
{{ "Hello, world. Goodbye, world." | remove_first: "world" }}
Copied!
Output
1
Hello, . Goodbye, world.
Copied!

replace

Replaces all occurrences of a string with a substring.
Input
1
<!-- product.title = "Awesome Shoes" -->
2
{{ product.title | replace: 'Awesome', 'Mega' }}
Copied!
Output
1
Mega Shoes
Copied!

replace_first

Replaces the first occurrence of a string with a substring.
Input
1
<!-- product.title = "Awesome Awesome Shoes" -->
2
{{ product.title | replace_first: 'Awesome', 'Mega' }}
Copied!
Output
1
Mega Awesome Shoes
Copied!

slice

The slice filter returns a substring, starting at the specified index. An optional second parameter can be passed to specify the length of the substring. If no second parameter is given, a substring of one character will be returned.
Input
1
{{ "hello" | slice: 0 }}
2
{{ "hello" | slice: 1 }}
3
{{ "hello" | slice: 1, 3 }}
Copied!
Output
1
h
2
e
3
ell
Copied!
If the passed index is negative, it is counted from the end of the string.
Input
1
{{ "hello" | slice: -3, 2 }}
Copied!
Output
1
ll
Copied!

split

The split filter takes on a substring as a parameter. The substring is used as a delimiter to divide a string into an array. You can output different parts of an array using array filters.
Input
1
{% assign words = "Hi, how are you today?" | split: ' ' %}
2
3
{%- for word in words -%}
4
{{ word }}
5
{% endfor %}
Copied!
Output
1
Hi,
2
how
3
are
4
you
5
today?
Copied!

strip

Strips tabs, spaces, and newlines (all whitespace) from the left and right side of a string.
Input
1
{{ ' too many spaces ' | strip }}
Copied!
Output
1
too many spaces
Copied!

lstrip

Strips tabs, spaces, and newlines (all whitespace) from the left side of a string.
Input
1
{{ ' too many spaces ' | lstrip }}!
Copied!
Output
1
too many spaces !
Copied!

rstrip

Strips tabs, spaces, and newlines (all whitespace) from the right side of a string.
Input
1
{{ ' too many spaces ' | rstrip }}!
Copied!
Output
1
too many spaces!
Copied!

strip_html

Strips all HTML tags from a string.
Input
1
{{ "<h1>Hello</h1> World" | strip_html }}
Copied!
Output
1
Hello World
Copied!

strip_newlines

Removes any line breaks/newlines from a string.
Input
1
{%- capture string_with_newlines -%}
2
Hello
3
there
4
{%- endcapture -%}
5
6
{{ string_with_newlines | strip_newlines }}
Copied!
Output
1
Hellothere
Copied!

truncate

Truncates a string down to the number of characters passed as the first parameter. An ellipsis (...) is appended to the truncated string and is included in the character count.
Input
1
{{ "The cat came back the very next day" | truncate: 13 }}
Copied!
Output
1
The cat ca...
Copied!

Custom ellipsis

truncate takes an optional second parameter that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (...), but you can specify a different sequence.
The length of the second parameter counts against the number of characters specified by the first parameter. For example, if you want to truncate a string to exactly 10 characters, and use a 3-character ellipsis, use 13 for the first parameter of truncate, since the ellipsis counts as 3 characters.
Input
1
{{ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | truncate: 18, ", and so on" }}
Copied!
Output
1
ABCDEFG, and so on
Copied!

No ellipsis

You can truncate to the exact number of characters specified by the first parameter and show no trailing characters by passing a blank string as the second parameter:
Input
1
{{ "I'm a little teapot, short and stout." | truncate: 15, "" }}
Copied!
Output
1
I'm a little te
Copied!

truncatewords

Truncates a string down to the number of words passed as the first parameter. An ellipsis (...) is appended to the truncated string.
Input
1
{{ "The cat came back the very next day" | truncatewords: 4 }}
Copied!
Output
1
The cat came back...
Copied!

Custom ellipsis

truncatewords takes an optional second parameter that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (...), but you can specify a different sequence.
Input
1
{{ "The cat came back the very next day" | truncatewords: 4, "--" }}
Copied!
Output
1
The cat came back--
Copied!

No ellipsis

You can avoid showing trailing characters by passing a blank string as the second parameter:
Input
1
{{ "The cat came back the very next day" | truncatewords: 4, "" }}
Copied!
Output
1
The cat came back
Copied!

upcase

Converts a string into uppercase.
Input
1
{{ 'i want this to be uppercase' | upcase }}
Copied!
Output
1
I WANT THIS TO BE UPPERCASE
Copied!

url_decode

Decodes a string that has been encoded as a URL or by url_encode.
Input
1
{{ "%27Stop%21%27+said+Fred" | url_decode }}
Copied!
Output
1
'Stop!' said Fred
Copied!

url_encode

Converts any URL-unsafe characters in a string into percent-encoded characters.
Input
1
{{ "[email protected]" | url_encode }}
Copied!
1
john%40liquid.com
Copied!
Note that url_encode will turn a space into a + sign instead of a percent-encoded character.
Input
1
{{ "Tetsuro Takara" | url_encode }}
Copied!
Output
1
Tetsuro+Takara
Copied!

xml_escape

This is a special filter available in Exporteo to facilitate the setup of an XML output template.
Replaces characters that are special characters in XML documents.
Char
Escape String
<
&lt;
>
&gt;
"
&quot;
'
&apos;
&
&amp;
Input
1
{{ "Jane & Joe O'Neill" | xml_escape }}
Copied!
Output
1
Jane &amp; Joe O&apos;Neill
Copied!
Last modified 16d ago