Grouped by functionality.

This is a based info on the CloudCannon Jekyll cheatsheet. See also Liquid filters on Jekyll docs.

The items here are grouped and ordered by use, rather than alpabetically.

String filters

  • append
    {{ 'jekyll' | append: '.jpg' }}
  • prepend
    {{ 'Jekyll' | prepend: 'I love ' }}
  • slice
    {{ "hello" | slice: 0 }}
    {{ "hello" | slice: 1, 3 }}
  • markdownify
  • jsonify
    {{ my_var | jsonify }}
    {{ site.data.my_data | jsonify }}
  • inspect

    Show a value as a Ruby object. Useful for debugging. Especially useful if a value is possibly null and therefore invisible or if you have a data structure to understand.

    {{ my_var | inspect }}
    {{ site.page | inspect }}
  • date
  • default
    {% assign new_var = foo | default: 'fallback' %}
    {% assign new_var = bar.buzz | default: 'fallback' %}
  • replace
  • replace_first
  • strip
  • lstrip
  • rstrip
  • capitalize
  • downcase
  • upcase
  • split
    {{ my_str | split: ',' }}
  • truncate

    Truncate a string down to x characters

  • truncatewords

    Truncate a string down to x words

  • strip_html
  • strip_newlines

    Remove \n characters

  • newline_to_br

    Convert \n to two br tags

  • escape
  • escape_once
  • url_decode
  • url_encode
  • slugify
    {{ "The _config.yml file" | slugify }} <!-- the-config-yml-file -->

Array filters

  • join
    {{ my_array | join: ', ' }}
  • first
    {{ my_array | first }}
  • last
    {{ my_array | last }}
  • concat

    Combine to arrays - parameter must be of type array to avoid error

    ---
    foo:
      - abc
      - def
    bar:
      - 123
    ---
    {{ page.foo | concat: page.bar | inspect }}
  • slice
    ---
    foo: ['abc', 'def', 'ghi', 'jkl' ]
    ---
    {{ page.foo | slice: 0 | inspect }} <!-- ['abc'] -->
    {{ page.foo | slice: 1, 3 | inspect }} <!-- ["def", "ghi", "jkl"] -->
  • map
    {{ my_array | map: "some_attribute" }}
  • where
    {{ site.posts | where:"category", "foo" }}
    {{ page.people | where: "school", "Stanford" }}
  • where_expr
    {{ page.people | where_exp: "item", "item.name contains 'Jo'" }}
    {{ page.people | where_exp: "item", "item.year >= 2016" }}
    {{ page.people | where_exp: "item", "item.school != "Stanford" }}
  • group_by

    Provide the attribute name for an array of hashes and you’ll create an array of hashes with name as a string and items as an array of the original values (the attribute won’t be removed)

  • group_by_exp
    {{ page.people | group_by_exp: "item", "item.name | size" }}
    {{ page.people | group_by_exp: "item", "item.year | modulo: 2" }}
    {{ page.people | group_by_exp: "item", "item.school | replace: 'rd', 'ry' " }}
  • size
    {{ my_array | size }}
  • reverse
    {{ my_array | reverse }}
  • sort
    {{ my_array | sort }}
    {{ page.posts | sort: 'author' }}
  • sort_natural

    Sorts items in an array in case-insensitive order

    {% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
    {{ my_array | sort_natural | join: ", " }}
  • uniq
    {{ my_array | uniq }}
  • push

    Insert at the end of the array

    {% assign my_array = my_array | push: 'my value ' %}
  • pop

    Remove an item from the end of an array. Accepts optional param num which defaults to 1

    {% assign value = my_array | pop %}
    {% assign value = my_array | pop: 1 %}
  • unshift

    Insert at the start of the array

    {% assign my_array = my_array | unshift: 'my value ' %}
  • shift

    Remove an item from the start of an array. Accepts optional param num which defaults to 1

    {% assign value = my_array | shift %}
    {% assign value = my_array | shift: 1 %}
  • compact

    Removes any nil values from an array.

    {% assign site_categories = site.pages | map: "category" | compact %}

Maths

  • plus
    {{ 4 | plus: 2 }}
  • minus
  • times
  • divided_by
  • modulo
  • floor
  • ceil
  • round
  • abs
  • at_least

    Limits a number to a minimum value. Same as min(a, b) in other languages.

    {{ 4 | at_least: 3 }} <!-- 3 -- >
  • at_most

    Limits a number to a maximum value. Same as max(a, b) in other languages.