📝 Edit on GitHub
Filters
Resources
Reference docs
- Filters in Jekyll docs. See standard filters near the bottom.
- Filters in Shopify docs. Jekyll links to these.
Cheatsheets
- Jekyll Cheatsheet on CloudCannon
- Jekyll on DevHints
- gist
Filters
From tutorial
where
where: KEY, VALUE
e.g.
Warning - this will not raise an error if the page is not found.
{% assign item = site.pages | where: 'name', 'foo' | first %}
{% assign posts = site.posts | where: "categories", "Foo" %}
{% for post in posts limit: 5 %}
<li>{{ post.title}} </li>
{% endfor %}
group_by
{% assign items_grouped = site.posts | group_by: 'author' %}
{{ items_grouped }}
{"name"=>"sharath", "items"=>[#, #], "size"=>2}
{"name"=>"webjeda", "items"=>[#, #, #, #, #, #, #, #, #, #, #, #], "size"=>12}
{"name"=>"someone", "items"=>[#], "size"=>1}
plus
{% assign crumb_limit = forloop.index | plus: 1 %}
Array and for loop handling
size
{% if crumbs.size > 2 %}
limit
{% for crumb in crumbs limit: crumb_limit %}
{% endfor %}
offset
Do a slice ignoring the last item.
{% for crumb in crumbs offset: 1 %}
{% endfor %}
Similar to pop
except offet
preserves the original value.
{% assign foo = bar | pop %}
Longer form for interest:
{% assign foo = bar | slice: 0, -1 %}
You can’t pop from the front, but you can do a slice starting at 2nd element.
{% assign foo = slice: 1, foo.fize %}
unless, last, index
{% for crumb in crumbs offset: 1 %}
{% unless forloop.first %}
...
{% endunless %}
{% if forloop.last %}
...
{% else %}
{% assign crumb_limit = forloop.index | plus: 1 %}
...
{% endif %}
{% endfor %}
Full list
Grouped by functionality.
Array
The might work on an array too.
append
prepend
concat
join
first
last
slice
map
size
reverse
sort
sort_natural
uniq
remove
remove_first
compact - Removes any nil values from an array.
Text
date
replace
replace_first
escape
escape_once
default
strip
lstrip
rstrip
capitalize
downcase
upcase
strip_html
strip_newlines
split
newline_to_br
truncate
truncatewords
url_decode
url_encode
Maths and conditions
times
abs
divided_by
at_least
at_most
ceil
floor
minus
modulo
plus
round