For your convenience, here we present at least basic documentation for the complete set of Liquid. We are committed to building this resource into API docs that cleanly cover the various implementations of Liquid, especially between Jekyll’s implementation for “layouts” and “includes” to generate site HTML, and LiquiDoc’s implementation for prebuilding data into useful new source content.

Array Management Filters

Pop

Key

pop

Description

Remove an item from the end of an array

Examples
input
{{ page.tags | pop }}
output
["Seattle"]

Push

Key

push

Description

Insert an item at the end of an array

Examples
input
{{ page.tags | push: "Spokane" }}
output
["Seattle", "Tacoma", "Spokane"]

Shift

Key

shift

Description

Remove an item from the beginning of an array

Examples
input
{{ page.tags | shift }}
output
["Tacoma"]

Metastore list concat

Key

store_list_concat

Description

Concatenates each Array-formatted value of the same-named property across all nodes in an Array of Hashes (Metastore). Accepts an Array of Hashes and the keyname of a property to collect from.

Examples
input
{{ data.metastore | store_list_concat: "children" }}
Origin

LiquiDoc

Related

pop, push, shift, store_list_dupes, unshift

Metastore list duplicates

Key

store_list_dupes

Description

Returns a list of duplicate items among multiple Arrays across multiple same-named properties in an Array of Hashes (Metastore). Accepts an Array of Hashes and the keyname of a Scalar property to check; returns the names of duplicate properties.

Examples
input
{{ data.metastore | store_list_concat: "children" }}
Origin

LiquiDoc

Related

pop, push, shift, store_list_concat, unshift

Unshift

Key

unshift

Description

Insert an item at the beginning of an array

Examples
input
{{ page.tags | unshift: "Olympia" }}
output
["Olympia", "Seattle", "Tacoma"]

Array Organizing Filters

Group By

Key

group_by

Description

Group an array’s items by a given property.

Examples
input
{{ data.members | group_by:"year" }}
Origin

Jekyll

Related

group_by_exp, reverse, sort

Group By Expression

Key

group_by_exp

Description

Group an array’s items using a Liquid expression.

Examples
input
{{ data.members | group_by_exp: "item",
"item.grad_year | truncate: 3, ''" }}
output
[{"name"=>"201", "items"=>[...]},
{"name"=>"200", "items"=>[...]}]
Origin

Jekyll

Related

group_by, reverse, sort

Reverse

Key

reverse

Origin

Shopify

Related

group_by, group_by_exp, sort

Sort

Key

sort

Description

Sort an array. Optional arguments for hashes

  1. property name

  2. nils order (first or last).

Examples
input
{{ page.tags | sort }}
returns

A one-dimensional array, alphabetized

input
{{ site.posts | sort: "author" }}
returns

An array of hashes, alphabetized by the value of the author property

input
{{ site.pages | sort: "title", "last" }}
returns

An array of hashes, alphabetized by the title property’s values, with items lacking titles (nil) at the end

Origin

Jekyll

Related

group_by, group_by_exp, reverse

Array Select Filters

First

Key

first

Origin

Shopify

Related

last, sample, where, where_exp

Last

Key

last

Origin

Shopify

Related

first, sample, where, where_exp

Sample

Key

sample

Description

Pick a random value from an array. Optionally, pick multiple values.

Examples
input
{{ site.pages | sample }}
returns

An array containing one randomly chosen array item.

input
{{ site.pages | sample: 2 }}
returns

An array containing two randomly chosen array items.

Origin

Jekyll

Related

first, last, where, where_exp

Where

Key

where

Description

Select all the objects in an array where the key has the given value.

Notes

To express a lone result record, use result_var[0].

Examples
input
{{ users | where:"level",2 }}
input
{% assign member = users | where:"user","ava" %} {{ member[0] }}
output
{"user"=>"ava","grad_year"=>2014,"joined"=>"2019-01-22"}
Origin

Jekyll

Related

first, last, sample, where_exp

Where Expression

Key

where_exp

Description

Select all the objects in an array where the expression is true.

Examples
input
{{ data.members | where_exp:"item",
"item.grad_year < 2014" }}
output
[{"user"=>"ava","grad_year"=>2014},{"user"=>"julia","grad_year"=>2014}]
input
{{ data.members | where_exp:"item",
"item.projects contains 'foo'" }}
output
[{"project"=>"foobar"},{"project"=>"fooman"}]
Origin

Jekyll

Related

first, last, sample, where

Date Format Filters

Date to Long String

Key

date_to_long_string

Description

Format a date to long format.

Examples
input
{{ data.time | date_to_long_string }}
output
07 November 2008
input
{{ data.time | date_to_long_string: "ordinal" }}
output
7th November 2008

Date to RFC-822 Format

Key

date_to_rfc822

Description

Convert a Date into the RFC-822 format used for RSS feeds.

Examples
input
{{ data.time | date_to_rfc822 }}
output
Mon, 07 Nov 2008 13:07:54 -0800

Date to String

Key

date_to_string

Description

Convert a date to short format.

Examples
input
{{ data.time | date_to_string }}
output
07 Nov 2008
input
{{ data.time | date_to_string: "ordinal", "US" }}
output
Nov 7th, 2008

Date to XML Schema

Key

date_to_xml_schema

Description

Convert a Date into XML Schema (ISO 8601) format.

Examples
input
{{ "2008-11-07 1:07:54pm" | date_to_xmlschema }}
output
2008-11-07T13:07:54-08:00

Math Filters

Object Analysis Filters

Holds Liquid

Key

holds_liquid

Description

Returns true if a snippet of text contains Liquid markup tags.

Examples
input
{{ "{% assign var = 'anything' %}" | holds_liquid }}
output
true
Origin

LiquiDoc

Related

inspect, size

Inspect

Key

inspect

Description

Convert an object into its String representation for debugging.

Examples
input
{{ some_var | inspect }}
Origin

Jekyll

Related

holds_liquid, size

Size

Key

size

Origin

Shopify

Related

holds_liquid, inspect

Object Conversion Filters

Array to Sentence

Key

array_to_sentence_string

Description

Convert an array into a sentence. Useful for listing tags. Optional argument for connector.

Examples
input
{{ tags_array | array_to_sentence_string }}
output
foo, bar, and baz
input
{{ tags_array | array_to_sentence_string: "or" }}
output
foo, bar, or baz

Array to Serial

Key

array_to_serial

Description

Convert an array into a sentence. Useful for listing tags. Optional argument for connector.

Examples
input
{{ tags_array | array_to_serial }}
output
foo, bar, and baz
input
{{ tags_array | array_to_serial: "or" }}
output
foo, bar, or baz
input
{{ tags_array | shift | array_to_serial: "or" }}
output
foo or baz

Data To JSON

Key

jsonify

Description

Convert Hash or Array to JSON.

Examples
input
{{ data.projects | jsonify }}
output
<JSON object>

Hash Params to CLI Arguments

Key

to_cli_args

Description

Turn a Hash/Struct of key-value pairs into a string of CLI-formatted arguments. Accepts two arguments: a template and a delimeter. The first optional position is either the name of a stored Liquid template or an actual string of Liquid to match. Stored templates include:

hyph

-<key> <value>

hyphhyph

--<key> <value> (default)

dump

<key> <value>

paramequal

<key>=<value>

valonly

<value>

Second optional position is a delimeter.

Examples
input
{{ my_flat_hash | to_cli_args }}
output
--key1 valuu_one --key2 val_two --key3 'third value'
input
{{ my_flat_hash | to_cli_args: 'paramequal' }}
output
--key1 'valuu_one' --key2 'val_two' --key3 'third value'
input
{% capture argpattern %}{% raw %}{{opt}} {{arg | quote_wrap: '[]'}}{% endraw %}{% endcapture %}
{{ object | to_cli_args: argpattern, " | " }}
output
key1 [val 1] | key2 val2 | key3 | key4 [val four]

To Integer

Key

to_integer

Description

Convert a string or boolean to integer.

Examples
input
{{ true | to_integer }}
output
1
input
{% assign five = "5" | to_integer %}
{% if five == 5 %}Samesies!{% endif %}
output
Samesies!
input
{{ "five" | to_integer }}
output
0

Data objects to JSON

Key

to_json

Description

Turn any parameter or data object into JSON format.

Data objects to YAML

Key

to_yaml

Description

Turn any parameter or data object into YAML format.

String Analysis Filters

Pattern Match

Key

match

Description

Returns of string or number matches pattern.

Examples
input
{% assign matched = "testword" | match: "^.*word$" %} {% if matched %}It matched!{% endif %}
output
It matched!
Origin

LiquiDoc

Related

number_of_words

Number of Words

Key

number_of_words

Description

Count the number of words in a text.

Examples
input
{{ page.content | number_of_words }}
output
1337
Origin

Jekyll

Related

match

String Conversion Filters

Comment Wrap

Key

commentwrap

Examples
input
{{ comment_text | commentwrap: 25, "// " }}
output
// A string that is obviously longer
// than 25 characters

Normalize Whitespace

Key

normalize_whitespace

Description

Replace any occurrence of whitespace with a single space.

Examples
input
{{ "a    b" | normalize_whitespace }}
output
a b

Slugify

Key

slugify

Description

Convert a string into a lowercase URL "slug".

This is not the Jekyll version.
Examples
input
{{ "The _config.yml file" | slugify }}
output
the-config-yml-file
input
{{ "The _config.yml file" | slugify: "_" }}
output
the_config_yml_file

Smart Format

Key

smart_format

Description

Convert UTF-8 or HTML-tagged text to “curly” quotes, emdashes, copyright, trademark, etc.

Examples
input
{% capture statement %}“He said, ‘Away, Drake!’”{% endcapture %}
{{ statement | smart_format }}
output
“He said, ‘Away, Drake!’”
input
{% capture statement %}"He said, <b>'Away, Drake!'</b>"{% endcapture %}
{{ statement | smart_format }}
output
“He said, ‘Away, Drake!’”

Strip Tags

Key

strip_tags

Description

Remove HTML/XML tags from text. Also strips out comments, PHP and ERB style tags.

Examples
input
{{ 'Visit our <a href="http://example.com">website!</a>' | strip_tags }}
output
Visit our website!

Titlecase

Key

titlecase

Description

Format text appropriately for titles.

Examples
input
{{ "Q&A with Steve Jobs: 'That's what happens in technology'" || titlecase }}
output
Q&A With Steve Jobs: 'That's What Happens in Technology'

Wrap

Key

wrap

Examples
input
{{ "A string that is obviously longer than 25 characters" | wrap: 25 }}
output
A string that is obviously longer
than 25 characters

String Escape Filters

CGI Escape

Key

cgi_escape

Description

CGI escape a string for use in a URL. Replaces any special characters with appropriate %XX replacements. CGI escape normally replaces a space with a plus + sign.

Examples
input
{{ "foo, bar; baz?" | cgi_escape }}
output
foo%2C+bar%3B+baz%3F
Origin

Jekyll

Related

uri_escape, xml_escape

URI Escape

Key

uri_escape

Description

Percent encodes any special characters in a URI. URI escape normally replaces a space with %20. Reserved characters will not be escaped.

Examples
input
{{ "http://foo.com/?q=foo, \bar?" | uri_escape }}
output
http://foo.com/?q=foo,%20%5Cbar?
Origin

Jekyll

Related

cgi_escape, xml_escape

XML Escape

Key

xml_escape

Description

Escape some text for use in XML.

Examples
input
{{ "<strong>some text</strong>" | xml_escape }}
output
&lt;strong&gt;some text&lt;/strong&gt;
Origin

Jekyll

Related

cgi_escape, uri_escape

String Management Filters

Regular Expression Replace

Key

regexreplace

Description

Use regular expressions to match and replace text patterns.

Examples
input
{{ "name=content" | regexreplace: "^\=|\s$", ": " }}
output
name: content
input
{{ "name=content" | regexreplace: "([\w]+):\s([\w]+)", "\1=\2" }}
output
key=content
Origin

LiquiDoc

Related

append, lstrip, prepend, replace_regex, truncate

Regular Expression Replace

Key

replace_regex

Description

Use regular expressions to match and replace text patterns.

Examples
input
{{ "name=content" | replace_regex: "^\=|\s$", ": " }}
output
name: content
input
{{ "name=content" | replace_regex: "([\w]+):\s([\w]+)", "\1=\2" }}
output
key=content
Origin

LiquiDoc

Related

append, lstrip, prepend, regexreplace, truncate

Truncate

Key

truncate

String Recode Filters

Decode Entities

Key

decode_entities

Description

Turn HTML entities into Unicode characters.

Examples
input
{{ "&ldquo;Economy Hits Bottom,&rdquo; ran the headline" | decode_entities }}
output
“Economy Hits Bottom,” ran the headline

Encode Entities

Key

encode_entities

Description

Turn Unicode characters into their HTML equivilents.

Examples
input
{{ "“Economy Hits Bottom,” ran the headline" | encode_entities }}
output
&ldquo;Economy Hits Bottom,&rdquo; ran the headline

Sterilize

Key

sterilize

Description

Transliterate to ASCII and strip out any HTML/XML tags.

Examples
input
{{ "<b>nåsty</b>" | sterilize }}
output
nasty

Transliterate to ASCII

Key

transliterate

Description

Convert Unicode [and accented ASCII] characters to their plain-text ASCII equivalents.

Examples
input
{{ "šţɽĩɳģ" | transliterate }}
output
string