Liquid syntax
# Liquid code with syntax highlighting
{% assign variable = value | filter: filter_expression, 'or value' %}
{{ variable | default: value | default: "[default_value]" }}
{{ json | jsonify }}
{{ markdown | markdownify }}
{% include filename.ext arg = value %}
{% include_relative filename.ext argument = value %}
{% if true -%} then true {%- else -%} then otherwise {%- endif %}
{% unless true -%} normally {%- else -%} otherwise {%- endunless %}
{% case x %}{%- when a -%} x is a {%- else -%} otherwise {%- endcase %}
{% capture it %} capture block {% endcapture %}{{ it }}
{% comment %} comment block {% endcomment %}
{% assign numbers = (1..9) %}
{% if true and false or x == y %}{% endif %}
nil, “” and 0 are treated as false
controls
if true : then true
elsif true : then true
else : then otherwise
unless false : normally
unless true : otherwise
case x :
when a : x is a
else : otherwise
strings
string : " jAmEs, pEtErSoN . " [20 characters]
# replace: ',' | remove: '.' | strip
string : "jAmEs pEtErSoN" [16 characters]
# split: ' ' | join: ' '
string : "jAmEs pEtErSoN" [14 characters]
upcase : "JAMES PETERSON"
downcase : "james peterson"
capitalize : "James peterson"
# titleize is not working, you have to use titleized
titleize : "jAmEs pEtErSoN"
titleized : "James Peterson"
# downcase | replace: "james", "smith" | prepend: 'Mr. ' | append: ' Jr.'
string : "Mr Smith Peterson Jr" [20 characters]
slice : "Mr Smith Peters"
truncate : "Mr Smith Pet..."
date
date : 2005-03-09T20:10:30
date : Wednesday, March 09, 2005 @ 08:10:30 PM
now : Sunday, February 01, 2026 @ 09:13:06 PM
| %B | Full month name | November |
| %b | Abbreviated month name | Nov |
| %A | Full day name | Thursday |
| %a | Abbreviated day name | Thursday |
| %w | Day of the week as a number (0=Sunday, 6=Saturday) | 4 |
| %d | Month as a padded number (01-12) | 03 |
| %m | Month as a padded number (01-12) | 03 |
| %Y | Full year (4 digits) | 2005 |
| %y | Year as a padded number (2 digits) | 05 |
| %H | 24-hour clock (00-23) | 21 |
| %I | 12-hour clock (01-12) | 06 |
| %M | Minute as a padded number (00-59) | 01 |
| %S | Second as a padded number (00-59) | 02 |
| %p | AM/PM indicator (uppercase) | PM |
loops
{%- assign numbers = (1..9) %}
numbers : "1..9" [9 items]
numbers : 1,2,3,4,5,6,7,8,9
one : [1,"odd"]
two : [2,"even"]
# skipped 3
four : [4,"odd"]
five : [5,"even"]
# break at 6
# emptiness
Use {% break %} and {% continue %} to get out of a loop.
Use {% else %} to handle empty arrays.
list
{%- assign chars = 'a,m,b,n,c,o,z,y,x' | split: ',' %}
chars : [ambncozyx] [9 items]
jsonify : ["a","m","b","n","c","o","z","y","x"]
join : "a,m,b,n,c,o,z,y,x"
order : a ... x
loop : a-m-b-n-c-o-z-y-x
reverse : ["x","y","z","o","c","n","b","m","a"]
sort : ["a","b","c","m","n","o","x","y","z"]
slice : ["n","c","o"]
{%- assign fruits = 'apple,banana,cherry' | split: ',' %}
fruits : ["apple","banana","cherry"] [3 items]
{%- assign fruits = fruits | join: ',' | prepend: 'pear,' | append: ',durian' | split: ',' %}
fruits : ["pear","apple","banana","cherry","durian"] [5 items]
capture
captured block
Use markdownify before using it inside an HTML block.
raw
raw skips liquid.
But using white-space modifier - with it will cause build error.
{% raw %}{{ by | default: 'everything inside raw will be rendered as-is' }}{% endraw %}
Unsupported Liquid Syntaxes
Github Pages does not support echo and render at the moment.
{% echo 'echo' %}
{% render 'snippet',
card_title: "Coffee Maker",
card_description: "Brews perfect coffee every time."
%}
Looks like the following syntax isn’t working.
# Check a blanks against the blank keyword.
blank is not working
# Compare an emptiness against the empty keyword.
empty is not working