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 |
|
Description |
Remove an item from the end of an array |
- Examples
-
input
{{ page.tags | pop }}
output["Seattle"]
Origin | |
Related |
Push
Key |
|
Description |
Insert an item at the end of an array |
- Examples
-
input
{{ page.tags | push: "Spokane" }}
output["Seattle", "Tacoma", "Spokane"]
Origin | |
Related |
Shift
Key |
|
Description |
Remove an item from the beginning of an array |
- Examples
-
input
{{ page.tags | shift }}
output["Tacoma"]
Origin | |
Related |
Metastore list concat
Key |
|
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 |
Metastore list duplicates
Key |
|
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 |
Unshift
Key |
|
Description |
Insert an item at the beginning of an array |
- Examples
-
input
{{ page.tags | unshift: "Olympia" }}
output["Olympia", "Seattle", "Tacoma"]
Origin | |
Related |
Array Organizing Filters
Group By
Key |
|
Description |
Group an array’s items by a given property. |
- Examples
-
input
{{ data.members | group_by:"year" }}
Origin | |
Related |
Reverse
Key |
|
Origin | |
Related |
Sort
Key |
|
Description |
Sort an array. Optional arguments for hashes
|
- Examples
-
input
{{ page.tags | sort }}
returnsA one-dimensional array, alphabetized
input{{ site.posts | sort: "author" }}
returnsAn array of hashes, alphabetized by the value of the
author
propertyinput{{ site.pages | sort: "title", "last" }}
returnsAn array of hashes, alphabetized by the
title
property’s values, with items lacking titles (nil) at the end
Origin | |
Related |
Array Select Filters
Sample
Key |
|
Description |
Pick a random value from an array. Optionally, pick multiple values. |
- Examples
-
input
{{ site.pages | sample }}
returnsAn array containing one randomly chosen array item.
input{{ site.pages | sample: 2 }}
returnsAn array containing two randomly chosen array items.
Where
Key |
|
Description |
Select all the objects in an array where the key has the given value. |
Notes |
To express a lone result record, use |
- 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"}
Where Expression
Key |
|
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"}]
Date Format Filters
Date to Long String
Key |
|
Description |
Format a date to long format. |
- Examples
-
input
{{ data.time | date_to_long_string }}
output07 November 2008
input{{ data.time | date_to_long_string: "ordinal" }}
output7th November 2008
Origin | |
Related |
Date to RFC-822 Format
Key |
|
Description |
Convert a Date into the RFC-822 format used for RSS feeds. |
- Examples
-
input
{{ data.time | date_to_rfc822 }}
outputMon, 07 Nov 2008 13:07:54 -0800
Origin
Related |
Date to String
Key |
|
Description |
Convert a date to short format. |
- Examples
-
input
{{ data.time | date_to_string }}
output07 Nov 2008
input{{ data.time | date_to_string: "ordinal", "US" }}
outputNov 7th, 2008
Origin | |
Related |
Date to XML Schema
Key |
|
Description |
Convert a Date into XML Schema (ISO 8601) format. |
- Examples
-
input
{{ "2008-11-07 1:07:54pm" | date_to_xmlschema }}
output2008-11-07T13:07:54-08:00
Origin | |
Related |
Math Filters
Object Analysis Filters
Inspect
Key |
|
Description |
Convert an object into its String representation for debugging. |
- Examples
-
input
{{ some_var | inspect }}
Origin | |
Related |
Size
Key |
|
Origin | |
Related |
Object Conversion Filters
Array to Sentence
Key |
|
Description |
Convert an array into a sentence. Useful for listing tags. Optional argument for connector. |
- Examples
-
input
{{ tags_array | array_to_sentence_string }}
outputfoo, bar, and baz
input{{ tags_array | array_to_sentence_string: "or" }}
outputfoo, bar, or baz
Origin | |
Related |
|
Array to Serial
Key |
|
Description |
Convert an array into a sentence. Useful for listing tags. Optional argument for connector. |
- Examples
-
input
{{ tags_array | array_to_serial }}
outputfoo, bar, and baz
input{{ tags_array | array_to_serial: "or" }}
outputfoo, bar, or baz
input{{ tags_array | shift | array_to_serial: "or" }}
outputfoo or baz
Origin | |
Related |
|
Join
Key |
|
Origin | |
Related |
|
Data To JSON
Key |
|
Description |
Convert Hash or Array to JSON. |
- Examples
-
input
{{ data.projects | jsonify }}
output<JSON object>
Origin | |
Related |
|
Map
Key |
|
Origin | |
Related |
|
Slice
Key |
|
Origin | |
Related |
|
Hash Params to CLI Arguments
Key |
|
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 |
|
hyphhyph |
|
dump |
|
paramequal |
|
valonly |
|
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, " | " }}
outputkey1 [val 1] | key2 val2 | key3 | key4 [val four]
Origin |
LiquiDoc |
Related |
|
To Integer
Key |
|
Description |
Convert a string or boolean to integer. |
- Examples
-
input
{{ true | to_integer }}
output1
input{% assign five = "5" | to_integer %} {% if five == 5 %}Samesies!{% endif %}
outputSamesies!
input{{ "five" | to_integer }}
output0
Origin | |
Related |
|
Data objects to JSON
Key |
|
Description |
Turn any parameter or data object into JSON format. |
Origin |
LiquiDoc |
Related |
|
Data objects to YAML
Key |
|
Description |
Turn any parameter or data object into YAML format. |
Origin |
LiquiDoc |
Related |
|
String Analysis Filters
Pattern Match
Key |
|
Description |
Returns of string or number matches pattern. |
- Examples
-
input
{% assign matched = "testword" | match: "^.*word$" %} {% if matched %}It matched!{% endif %}
outputIt matched!
Origin |
LiquiDoc |
Related |
String Conversion Filters
Capitalize
Key |
|
Origin | |
Related |
|
Comment Wrap
Key |
|
- Examples
-
input
{{ comment_text | commentwrap: 25, "// " }}
output// A string that is obviously longer // than 25 characters
Origin |
LiquiDoc |
Related |
|
Downcase
Key |
|
Origin | |
Related |
|
Escape
Key |
|
Origin | |
Related |
|
Escape Once
Key |
|
Origin | |
Related |
|
Newline to Break Tag
Key |
|
Origin | |
Related |
|
Normalize Whitespace
Key |
|
Description |
Replace any occurrence of whitespace with a single space. |
- Examples
-
input
{{ "a b" | normalize_whitespace }}
outputa b
Origin | |
Related |
|
Remove
Key |
|
Origin | |
Related |
|
Remove First
Key |
|
Origin | |
Related |
|
Replace
Key |
|
Origin | |
Related |
|
Replace First
Key |
|
Origin | |
Related |
|
Right Strip
Key |
|
Origin | |
Related |
|
Slugify
Key |
|
||
Description |
Convert a string into a lowercase URL "slug".
|
- Examples
-
input
{{ "The _config.yml file" | slugify }}
outputthe-config-yml-file
input{{ "The _config.yml file" | slugify: "_" }}
outputthe_config_yml_file
Origin |
LiquiDoc |
Related |
|
Smart Format
Key |
|
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!’”
Origin | |
Related |
|
Strip
Key |
|
Origin | |
Related |
|
Strip HTML
Key |
|
Origin | |
Related |
|
Strip Newlines
Key |
|
Origin | |
Related |
|
Strip Tags
Key |
|
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 }}
outputVisit our website!
Origin | |
Related |
|
Titlecase
Key |
|
Description |
Format text appropriately for titles. |
- Examples
-
input
{{ "Q&A with Steve Jobs: 'That's what happens in technology'" || titlecase }}
outputQ&A With Steve Jobs: 'That's What Happens in Technology'
Origin | |
Related |
|
String to Slug
Key |
|
Description |
Simple slug converter. |
Origin | |
Related |
|
Truncate Words
Key |
|
Origin | |
Related |
|
Upcase
Key |
|
Origin | |
Related |
|
Wrap
Key |
|
- Examples
-
input
{{ "A string that is obviously longer than 25 characters" | wrap: 25 }}
outputA string that is obviously longer than 25 characters
Origin |
LiquiDoc |
Related |
|
String Escape Filters
CGI Escape
Key |
|
Description |
CGI escape a string for use in a URL. Replaces any special characters
with appropriate |
- Examples
-
input
{{ "foo, bar; baz?" | cgi_escape }}
outputfoo%2C+bar%3B+baz%3F
Origin | |
Related |
URI Escape
Key |
|
Description |
Percent encodes any special characters in a URI.
URI escape normally replaces a space with |
- Examples
-
input
{{ "http://foo.com/?q=foo, \bar?" | uri_escape }}
outputhttp://foo.com/?q=foo,%20%5Cbar?
Origin | |
Related |
XML Escape
Key |
|
Description |
Escape some text for use in XML. |
- Examples
-
input
{{ "<strong>some text</strong>" | xml_escape }}
output<strong>some text</strong>
Origin | |
Related |
String Management Filters
Append
Key |
|
Origin | |
Related |
Left Strip
Key |
|
Origin | |
Related |
Prepend
Key |
|
Origin | |
Related |
Regular Expression Replace
Key |
|
Description |
Use regular expressions to match and replace text patterns. |
- Examples
-
input
{{ "name=content" | regexreplace: "^\=|\s$", ": " }}
outputname: content
input{{ "name=content" | regexreplace: "([\w]+):\s([\w]+)", "\1=\2" }}
outputkey=content
Origin |
LiquiDoc |
Related |
Regular Expression Replace
Key |
|
Description |
Use regular expressions to match and replace text patterns. |
- Examples
-
input
{{ "name=content" | replace_regex: "^\=|\s$", ": " }}
outputname: content
input{{ "name=content" | replace_regex: "([\w]+):\s([\w]+)", "\1=\2" }}
outputkey=content
Origin |
LiquiDoc |
Related |
Truncate
Key |
|
Origin | |
Related |
String Recode Filters
Decode Entities
Key |
|
Description |
Turn HTML entities into Unicode characters. |
- Examples
-
input
{{ "“Economy Hits Bottom,” ran the headline" | decode_entities }}
output“Economy Hits Bottom,” ran the headline
Origin | |
Related |
|
Encode Entities
Key |
|
Description |
Turn Unicode characters into their HTML equivilents. |
- Examples
-
input
{{ "“Economy Hits Bottom,” ran the headline" | encode_entities }}
output“Economy Hits Bottom,” ran the headline
Origin | |
Related |
|
Sterilize
Key |
|
Description |
Transliterate to ASCII and strip out any HTML/XML tags. |
- Examples
-
input
{{ "<b>nåsty</b>" | sterilize }}
outputnasty
Origin | |
Related |
|
Transliterate to ASCII
Key |
|
Description |
Convert Unicode [and accented ASCII] characters to their plain-text ASCII equivalents. |
- Examples
-
input
{{ "šţɽĩɳģ" | transliterate }}
outputstring
Origin | |
Related |
|
URL Decode
Key |
|
Origin | |
Related |
|
URL Encode
Key |
|
Origin | |
Related |
|