Liquid tag master list Liquid tag master list

This table should give you an idea of which Liquid tags and variables are available to you in Our version of Liquid is currently 2.5.3, so that dictates what we have available, as we're behind the original source code. Tag-specific syntax can be found here.

In the below table, we have standard liquid, liquid specific to (" Tag" and " Filter"), array and string filters.

For array filters, assume you have the following array: acme.characters = "coyote", "bugs", "tweety".

Looking for something specific?

TypeThe LiquidWhat does it do? Tag{{content}}the tag used in layouts to indicate where the code added via the email editor will be included Tag{% unsubscribe_url %}This tag renders a unique unsubscribe link for that customer and email. Tag{% view_in_browser_url %}Our default link that generates a web version of your email, personalized for each recipient. Looks something like: Tag{{}}The numerical ID associated with the email layout you've used. Tag{{}The name you've assigned to the email layout you've used. Tag{{}}Your campaign's numerical ID. This can be found in your campaign URL. For example, the campaign ID here is 2000: Tag{{}}This tag will output the name you've given your campaign or newsletter in the interface. For example: "Q2 Anvil Onboarding Campaign [Coyotes]" Tag{{campaign.type}}This returns whether or not your campaign is behavioral (segment triggered), transactional (event triggered), or a newsletter Tag{{}}The numerical ID associated with a message action in the workflow— i.e. an SMS action might have a {{}} of 200. Every SMS it generates has a different {{delivery_id}}. Tag{{message.journey_id}}The ID for the path a person went through in a Campaign or API Triggered Broadcast workflow. This can be used to trace message metrics back to a person's unique workflow journey using the value sent in our Reporting Webhooks. Tag{{}}The name you give your message in the workflow. E.g. "Welcome to ACME!" Tag{{message.type}}This refers to a particular message's type. Possible values are: email_action, twilio_action, slack_action, webhook_action, urban_airship_action, attribute_update_action Tag{{message.subject}}If your message has a subject (or if it's different to the message name) this tag will echo it. Tag{{event_name}}The name of the event that powers your event triggered campaign. Tag{{event_timestamp}}The UNIX timestamp for when a particular event was performed. Keep in mind that this is different from 'now'! TagnowThe current time in UTC. Needs to be formatted with date. e.g. {{ 'now' | date: '%H:%M %p %B %d, %Y' }} returns the current time in this format: 06:54 AM August 31, 2017.
To use any of the add filters you will need to convert 'now' into something usable first. E.g., {{ 'now' | date: '%s' | plus: 0 | add_day: 1 | date: '%Y-%m-%d %H:%M'}} Tag{{delivery_id}}A URL-compatible base64 string that identifies a specific message created for an end-user. This is set to unsent in test send and composer previews, and generated when the message is drafted or sent. FilterfloorRounds a number down to the nearest integer. e.g.{{ 4.637 | floor }} will output 4 FilterceilRounds a number up to the nearest integer. e.g.{{ 4.637 | ceil }} will output 5 FilterabsReturns the absolute value of a number. e.g.{{ 4.637 | abs }} will output 4.637 FilterroundRounds a number up or down to the nearest integer, or to a decimal you specify. e.g.{{ 4.637 | round }} will output 5, while {{ 4.637 | round: 2 }} will output 4.64 Filterrounded_currencyRounds a number into the nearest whole integer, and formats it to a currency. e.g.{{ 8.01234 | rounded_currency }} outputs $8. We don't have the locale: option here. Filternumber_with_delimiterAdds a delimeter to a number. e.g. {{ 10000 | number_with_delimiter }} outputs 10,000. We don't have the option to specify the delimiter here so the default , delimiter will be used. Filternumber_to_currencyFormats a number into a currency. e.g. {{ 8 | number_to_currency }} outputs $8.00. We don't have the locale: option here.
String FilterescapeEscaping (or encoding) a string removes special characters. e.g.
{{ "Hey there, world!" | escape }} will output
{{ "" | escape }} will output
String Filterescape_onceEscapes or encodes a string, but doesn't include already-escaped characters. e.g.
{{ "1 < 2 & 3" | escape_once }} will output
1 < 2 & 3 FilterhtmlencodeEscapes HTML characters into HTML entities. FilterurlencodeEscapes/encodes any URL-unsafe characters in a string. e.g.
{{ "Hello, world!" | urlencode }} outputs
Hello,%20world! Note, for email addresses, you will want to use the 'escape' filter below as some characters that are allowed in email addresses (i.e., + and @) are not considered URL-unsafe characters and they will not be replaced by this filter. Filterbase64Base64-encodes a string. {{ 'Hello, world!' | base64 }} returns SGVsbG8sIHdvcmxkIQ==. Filteradd_yearAdds a year, or multiple years, to a given timestamp e.g. {{ 1477430251 | add_year }} outputs 1508966251. You can also use {{ 1477430251 | add_year: 4 }} Filteradd_monthAdds a month, or multiple months, to a given timestamp e.g. {{ 1477430251 | add_month }} outputs 1480108651. You can also use {{ 1477430251 | add_month: 2 }} Filteradd_dayAdds a day, or multiple days, to a given timestamp e.g. {{ 1477430251 | add_day }} outputs 1477516651. You can also use {{ 1477430251 | add_day: 7 }} FiltertimezoneConverts a timestamp to a timezone you specify. e.g. {{ 1483272000 | timezone: 'US/Pacific' | date: '%H:%M, %a, %b %d, %Y'}} outputs 04:00, Sun, Jan 01, 2017. You can also use 'now' instead of a timestamp. Timezone inputs can be: timezone: '-3' (specify your number) or UTC Filterto_jsonOuputs the json representation of the input e.g. {{ customer | to_json }} will send all your customer data into a JSON variable. FilterrandomGenerates a random number between 0 and NUM. e.g. {% random 10 %} will generate a random number between 0 and 10.
Standard LiquiddateReformat a date. e.g. {{ 1483272000 | date: '%H:%M, %a, %b %d, %Y'}} will output 12:00, Sun, Jan 01, 2017. Here's a syntax reference
Standard LiquidcapitalizeCapitalize the first character in a string. e.g. {{ "hello, world" | capitalize }} will output Hello, world
Standard LiquiddowncaseConverts a string to lower case. e.g. {{ "ACME" | downcase }} will output acme
Standard LiquidupcaseConverts a string to upper case. e.g. {{ "acme" | upcase }} will output ACME
Standard LiquidtitlecaseConverts a string to title case. e.g. {{ "rocket roller skates" | titlecase }} will output Rocket Roller Skates
Array FilterfirstReturns the first element of the array. e.g. {{ acme.characters | first }} will output coyote
Array FilterlastReturns the last element of the array. e.g. {{ acme.characters | last }} will output tweety
Array FilterjoinJoins the elements of an array with the character passed as the parameter. e.g. {{ acme.characters | join: ', ' }} will output coyote, bugs, tweety
Array FiltersortSorts the elements of an array by a given attribute of an element in that array. Usually used with a 'for' loop. See this example, and remember that the order of the sorted array is case-sensitive!
Array FiltermapCreates an array of values by extracting the values of a named property from another object. If you have the object: "[{""name"":""coyote""},{""name"":""bugs""},{""name"":""tweety""}]", you can use map like this, to create a new array of the character names:

assign names = customer.characters | map: 'name' %}

Then, to output them, you can use a 'for' loop. See syntax.

Array FiltersizeReturns the size of a string (in characters) or an array (number of elements). e.g. {{ "That's all, folks!" | size }} will output 18
String FiltersliceReturns the character located at the index specified in the first argument.
{{ "" | slice: 0 }} will output C
{{ "" | slice: 3 }} will output t

For more than one character, include a second argument to specify how many characters to return. e.g.:
{{ "" | slice: 3, 3 }} will output tom

When the first argument is a negative number, the index is counted from the end of the string. e.g.:
{{ "" | slice: '-4', 3 }} will output r.i
String Filterstrip_htmlRemoves HTML characters from a string. e.g. {{ "Eh, what's <i>up</i>, <b>Doc<b>?" | strip_html }} will output Eh, what's up, Doc?
String Filterstrip_newlinesRemoves line breaks (\n) from a string. e.g. {{ product.description | strip_newlines }} will remove all line breaks from your product description, if there are any.
String Filternewline_to_brReplaces newline with an HTML line break. See this example for output.
String FilterreplaceReplace each occurrence of A with B. e.g. {{ "Coyotes never catch roadrunners!" | replace: "never", "always" }} will output Coyotes always catch roadrunners!
String Filterreplace_firstSame as above, but only replaces the first instance of A. e.g. {{ "roller rocket roller skates" | replace_first: "roller", "awesome" }} will output awesome rocket roller skates
String FilterremoveRemoves a specified item from a string. e.g. {{ "And that's all, folks!" | remove: ", folks" }} will output And that's all!
String Filterremove_firstRemoves the first occurrence of a specified item from a strong. e.g. {{ "folks that's all folks!" | remove_first: "folks" }} will output that's all folks!
String FiltertruncateShortens a string down to the given number of characters, adding an ellipsis. e.g. {{ "I knew I shoulda taken that left turn at Albuquerque." | truncate: 20 }} will output I knew I shoulda ...
String FiltertruncatewordsShortens a string down to the number of words passed, instead of characters, and adds an ellipsis. e.g. {{ "I knew I shoulda taken that left turn at Albuquerque." | truncatewords: 8 }} will output I knew I shoulda taken that left turn...
String FilterprependAdds a specified string to the beginning of another string. e.g. {{ "Sufferin' succotash!" | prepend: "Sylvester: " }} will output Sylvester: Sufferin' succotash!
String FilterappendPuts together two strings. e.g. {{ "What's all the hubbub, " | append: "bub?" }} will output What's all the hubbub, bub?
String FiltersplitDivides an input string into an array using a separator you define. Often used with a for loop. See this Beatles example.
String FilteruniqRemoves duplicate elements in an array.
Using {{ my_array | uniq | join: ", " }} on my_array containing "lions, tigers, bears, bears, lions" will output lions, tigers, bears
String Filtermd5Converts a string into an md5 hash.
{{ "" | md5 }} will output d52b6a207bf5255c05b1d0056230617e
String Filtersha1Converts a string into a sha1 hash.
{{ "" | sha1 }} will output c197ff0ae0a41983362f35ca972c544061c54d4c
String Filtersha256Converts a string into a sha256 hash.
{{ "" | sha256: "some_key" }} will output 6dddb773238216bce273133bc3f6a12a824f41dd184d09452f05c7659dae7d57
String Filterhmac_sha1Converts a string into an hmac_sha1 hash.
{{ "" | hmac_sha1: "some_key" }} will output 2bdf556c9a75766f258d1e2824f6d0e31d1beedc
String Filterhmac_sha256Converts a string into an hmac_sha256 hash.
{{ "" | hmac_sha256: "some_key" }} will output 6dddb773238216bce273133bc3f6a12a824f41dd184d09452f05c7659dae7d57
String Filterhex_base64Returns a base64 encoding of a hex digest such as ones returned by the hmac_sha256 filter.
{{ "" | hmac_sha256: "some_key" | hex_base64 }} will output bd23cyOCFrzicxM7w/ahKoJPQd0YTQlFLwXHZZ2ufVc=
Math FilterminusSubtracts a number from another number. e.g. {{ 10 | minus: 1 }} will output 9
Math FilterplusAdds a number to another. e.g. {{ 10 | plus: 1 }} will output 11
Math FiltertimesMultiplies a number by another. e.g. {{ 5 | times: 2 }} will output 10
Math Filterdivided_byDivides a number by a number you specify. e.g. {{ 10 | divided_by: 4 }} will output 2, while {{ 10 | divided_by: 4.0 }} will return 2.5
Math FiltermoduloReturns the remainder of division. e.g. {{ 3 | modulo: 2 }} will output 1
Math FiltercurrencyConverts an integer to currency. e.g. {{ 10 | currency }} will output $10.00
Standard TagcommentDoesn't show the content inside of it. e.g. {% comment %} Don't display me! {% endcomment %}
Standard TagassignAssigns a specific value to a variable. e.g. {% assign favorite_food = 'apples' %} creates {{ favorite_food }}
Standard TagcaptureCaptures a string and assigns it to a variable. e.g. {% capture about_me %}I am 28 and my favorite food is pasta.{% endcapture %} creates {{ about_me }}
Standard TagcaseCreates a switch statement that depends on a variable's specific value. For example, you might use this to display different text depending on if a customer lives in a specific country.
Standard Tag cycle Loops through strings and outputs them in the order they were passed. It needs to be used in a 'for' loop! So if you have the array ["coyote","bugs","tweety"] held in a customer attribute, you can do this:
{% for character in customer.characters %}
<li class="{% cycle 'odd', 'even' %}">{{ character }}</li>
{% endfor %}

This will output:
  • coyote
  • bugs
  • tweety

  • With alternating 'odd' and 'even' CSS classes, like this:
    <li class="odd">coyote</li>
    <li class="even">bugs</li>
    <li class="odd">tweety</li>
    Standard TagforRepeatedly executes a block of code. See syntax here.
    Standard TagifExecutes a block of code if a certain condition is met. See syntax here.
    Standard TagunlessLike if, but this code is executed if a certain condition is not met. See syntax here.
    Standard TagrawTemporarily disable Liquid processing. See syntax here.

    Need help?

    For all of the above tags, we have our own syntax guide which we've linked above. If you need specific guidance wth how to use a particular tag with, let us know!

    Was This Article Helpful?