Jekyll logo

Jekyll Cheatsheet

Learn everything Jekyll is capable of from an exhaustive list of variables, tags, and filters.

Collection variables Docs

  • directory

    The full path to the collections's source directory.

    Input
    {{ site.my_collection.directory }}
    Output
    /Users/mike/jekyll-project/_my_collection
  • docs

    An array of the collection's documents.

    Input
    {{ site.my_collection.docs.first.url }}
    Output
    /my_collection/item.html
  • files

    An array of static files in the collection.

    Input
    {{ site.my_collection.files | size }}
    Output
    0
  • label

    The name of your collection.

    Input
    {{ site.my_collection.label }}
    Output
    my_collection
  • output

    Whether the collection's documents will be output as individual files.

    Input
    {{ site.my_collection.output }}
    Output
    true
  • relative_path

    The path to the document's source file relative to the site source.

    Input
    {{ site.collections.my_collection.relative_path }}
    Output
    _my_collection

Document variables Docs

  • collection

    Label of the containing collection.

    Input
    {{ site.my_collection.first.collection }}
    Output
    my_collection
  • content

    The content of the collection item, rendered or un-rendered depending upon what Liquid is being processed and the item is.

    Input
    {{ site.my_collection.first.content }}
    Output
    Hello from my_collection.
  • relative_path

    The path to the document's source file relative to the site source.

    Input
    {{ site.my_collection.first.relative_path }}
    Output
    _my_collection/item.md

Global variables Docs

  • content

    In layout files, the rendered content of the Post or Page being wrapped. Not defined in Post or Page files.

  • page

    Page specific information + the YAML front matter. Custom variables set via the YAML Front Matter will be available here.

  • site

    Sitewide information + configuration settings from `_config.yml`.

Liquid filters - array Docs

  • array_to_sentence_string

    Append characters to a string.

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {{ page.my_array | array_to_sentence_string }}
    {{ page.my_array | array_to_sentence_string: 'or' }}
    Output
    a, b, and c
    a, b, or c
  • first

    Get the first element of the passed in array.

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {{ page.my_array | first }}
    Output
    a
  • group_by

    Group an array's items by a given property.

    Input
    <!-- page.people is
    - name: "John"
    school: "Stanford"
    - name: "Jane"
    school: "Stanford"
    - name: "Joe"
    school: "Harvard"
    -->

    {{ page.people | group_by: "school" }}
    Output
    {
    "name"=>"Stanford",
    "items"=>[{
    "name"=>"John",
    "school"=>"Stanford"
    }, {
    "name"=>"Jane",
    "school"=>"Stanford"
    }]
    },
    {
    "name"=>"Harvard",
    "items"=>[{
    "name"=>"Joe",
    "school"=>"Harvard"
    }]
    }
  • group_by_exp

    Group an array's items using a Liquid expression.

    Input
    <!-- page.people is
    - name: "John"
    school: "Stanford"
    year: 2016
    - name: "Jane"
    school: "Stanford"
    year: 2017
    - name: "Joe"
    school: "Harvard"
    year: 2015
    -->

    {{ 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' " }}
    Output
    {"name"=>4, "items"=>[{"name"=>"John", "school"=>"Stanford", "year"=>2016}, {"name"=>"Jane", "school"=>"Stanford", "year"=>2017}], "size"=>2}{"name"=>3, "items"=>[{"name"=>"Joe", "school"=>"Harvard", "year"=>2015}], "size"=>1}

    {"name"=>0, "items"=>[{"name"=>"John", "school"=>"Stanford", "year"=>2016}], "size"=>1}{"name"=>1, "items"=>[{"name"=>"Jane", "school"=>"Stanford", "year"=>2017}, {"name"=>"Joe", "school"=>"Harvard", "year"=>2015}], "size"=>2}

    {"name"=>"Stanfory", "items"=>[{"name"=>"John", "school"=>"Stanford", "year"=>2016}, {"name"=>"Jane", "school"=>"Stanford", "year"=>2017}], "size"=>2}{"name"=>"Harvary", "items"=>[{"name"=>"Joe", "school"=>"Harvard", "year"=>2015}], "size"=>1}
  • join

    Joins an array with the specified character.

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {{ page.my_array | join: ', ' }}
    Output
    a, b, c
  • jsonify

    Convert Hash or Array to JSON.

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {{ page.my_array | jsonify }}
    Output
    ["a","b","c"]
  • last

    Get the last element of the passed in array.

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {{ page.my_array | last }}
    Output
    c
  • map

    Accepts an array element's attribute as a parameter and creates a string out of each array element's value.

    Input
    <!-- page.people is
    - name: "John"
    school: "Stanford"
    - name: "Jane"
    school: "Stanford"
    - name: "Joe"
    school: "Harvard"
    -->

    {{ page.people | map: "name" }}
    Output
    JohnJaneJoe
  • push

    Adds an object to a array.

    Input
    {% assign my_array = "a,b,c" | split:"," %}
    {% assign my_array = my_array | push: 'd' %}

    {{ my_array | array_to_sentence_string }}
    Output
    a, b, c, and d
  • size

    Return the size of an array or string.

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {{ page.my_array | size }}
    Output
    3
  • sort

    Sorts an array.

    Input
    <!-- page.my_array is ['c', 'a', 'b'] -->
    {{ page.my_array | sort }}
    Output
    ['a','b','c']

    You can add a argument to sort on a property name:

    Input
    {{ page.posts | sort: 'author' }}

    And also add a second argument to say whether the nils should be first or last:

    Input
    {{ page.posts | sort: 'author', 'last' }}
  • uniq

    Removes duplicate elements from an array.

    Input
    <!-- page.my_array is ['cat', 'dog', 'mouse', 'cat'] -->
    {{ page.my_array | uniq }}
    Output
    'cat', 'dog', 'mouse'
  • where

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

    Input
    <!-- page.people is
    - name: "John"
    school: "Stanford"
    - name: "Jane"
    school: "Stanford"
    - name: "Joe"
    school: "Harvard"
    -->

    {{ page.people | where: "school", "Stanford" }}
    Output
    {"name"=>"John", "school"=>"Stanford"}{"name"=>"Jane", "school"=>"Stanford"}
  • where_exp

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

    Input
    <!-- page.people is
    - name: "John"
    school: "Stanford"
    year: 2016
    - name: "Jane"
    school: "Stanford"
    year: 2017
    - name: "Joe"
    school: "Harvard"
    year: 2015
    -->

    {{ 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" }}
    Output
    {"name"=>"John", "school"=>"Stanford", "year"=>2016}{"name"=>"Joe", "school"=>"Harvard", "year"=>2015}

    {"name"=>"John", "school"=>"Stanford", "year"=>2016}{"name"=>"Jane", "school"=>"Stanford", "year"=>2017}

    {"name"=>"Joe", "school"=>"Harvard", "year"=>2015}

Liquid filters - date Docs

  • date

    Converts a date into another format.

    Input
    {{ site.time | date: "%a, %b %d, %y" }}
    Output
    Wed, Jan 27, 16
    • %a - Abbreviated weekday (Sun)
    • %A - Full weekday name (Sunday)
    • %b - Abbreviated month name (Jan)
    • %B - Full month name (January)
    • %c - Preferred local date and time representation (Fri Jan 29 11:16:09 2016)
    • %d - Day of the month, zero-padded (05)
    • %-d - Day of the month (5)
    • %D - Formats the date (29/01/16).
    • %e - Day of the month (3).
    • %F - Returns the date in ISO 8601 format (2016-01-29).
    • %H - Hour of the day, 24-hour clock (07)
    • %I - Hour of the day, 12-hour clock (04)
    • %j - Day of the year (017)
    • %k - Hour of the day, 24-hour clock (7)
    • %m - Month of the year (04)
    • %M - Minute of the hour (09)
    • %p - Meridian indicator uppercase (AM)
    • %P - Meridian indicator lowercase (pm)
    • %r - 12-hour time (01:31:43 PM)
    • %R - 24-hour time (18:09)
    • %T - 24-hour time with seconds (18:09:13)
    • %s - Number of seconds since 1970-01-01 00:00:00 UTC (1452355261)
    • %S - Second of the minute (05)
    • %U - Week number of the current year, starting with the first Sunday as the first day of the first week (03)
    • %W - Week number of the current year, starting with the first Monday as the first day of the first week (09)
    • %w - Day of the week. Sunday is 0 (4)
    • %x - Preferred representation for the date (05/11/15)
    • %X - Preferred representation for the time (17:15:31)
    • %y - Year without a century (16)
    • %Y - Year with century (2016)
    • %Z - Time zone name (PST)
    • %% - Literal % character
  • date_to_long_string

    Convert a date to long format.

    Input
    {{ site.time | date_to_long_string }}
    Output
    01 January 2016
  • date_to_long_rfc822

    Convert a Date into RFC-822 format.

    Input
    {{ site.time | date_to_rfc822 }}
    Output
    Mon, 07 Nov 2008 13:07:54 -0800
  • date_to_string

    Convert a date to short format.

    Input
    {{ site.time | date_to_string }}
    Output
    01 Jan 2016
  • date_to_xmlschema

    Convert a Date into ISO 8601 format.

    Input
    {{ site.time | date_to_xmlschema }}
    Output
    2008-11-07T13:07:54-08:00

Liquid filters - integer Docs

  • ceil

    Rounds a number up to the nearest whole number.

    Input
    {{ 1.2 | ceil }}
    Output
    2
  • divided_by

    Integer division.

    Input
    {{ 10 | divided_by:3 }}
    Output
    3
  • floor

    Rounds a number down to the nearest whole number.

    Input
    {{ 1.2 | floor }}
    Output
    1
  • minus

    Subtraction.

    Input
    {{ 4 | minus:1 }}
    Output
    3
  • modulo

    Remainder.

    Input
    {{ 3 | modulo:2 }}
    Output
    1
  • plus

    Addition.

    Input
    {{ 4 | plus:1 }}
    Output
    5
  • round

    Rounds a number to the nearest whole number.

    Input
    {{ 1.8 | round }}
    Output
    2
  • times

    Integer multiplication.

    Input
    {{ 10 | times:3 }}
    Output
    30

Liquid filters - string Docs

  • absolute_url

    Prepend the `baseurl` and `url` to the input.

    Input
    <!-- baseurl is set to "/mysite" in _config.yml -->
    <!-- url is set to "http://example.com" in _config.yml -->
    {{ '/images/dog.jpeg' | absolute_url }}
    Output
    http://example.com/mysite/images/dog.jpeg
  • append

    Append characters to a string.

    Input
    {{ 'jekyll' | append: '.jpg' }}
    Output
    jekyll.jpg
  • capitalize

    Capitalizes the first character.

    Input
    {{ "static site generator" | capitalize }}
    Output
    Static site generator
  • cgi_escape

    Escape a string for use in a URL.

    Input
    {{ "foo,bar;baz?" | cgi_escape }}
    Output
    foo%2Cbar%3Bbaz%3F
  • default

    Set a fallback incase a value doesn't exist.

    Input
    {{ nil | default: "hello"  }}
    Output
    hello
  • downcase

    Converts a string to lowercase.

    Input
    {{ "STATIC Site generator" | downcase }}
    Output
    static site generator
  • escape

    Returns an escaped version of html.

    Input
    {{ "<p>Jekyll</p>" | escape }}
    Output
    &amp;lt;p&amp;gt;Jekyll&amp;lt;/p&amp;gt;
  • lstrip

    Removes whitespace characters from the beginning of a string.

    Input
    {{ '          I love Jekyll!          ' | lstrip }}
    Output
    I love Jekyll!          
  • markdownify

    Convert a Markdown-formatted string into HTML.

    Input
    {{ "Hello **Jekyll**" | markdownify }}
    Output
    Hello <strong>Jekyll</strong>
  • number_of_words

    Count the number of words in a string.

    Input
    {{ "Hi Jekyll!" | number_of_words }}
    Output
    2
  • prepend

    Prepend characters to a string.

    Input
    {{ 'Jekyll' | prepend: 'I love ' }}
    Output
    I love Jekyll
  • relative_url

    Prepend the `baseurl` value to the input.

    Input
    <!-- baseurl is set to "/mysite" in _config.yml -->
    {{ '/images/dog.jpeg' | relative_url }}
    Output
    /mysite/images/dog.jpeg
  • remove

    Removes any occurrence of a substring from a string.

    Input
    {{ 'I really really like Jekyll' | remove: 'really' }}
    Output
    I like Jekyll
  • remove_first

    Removes only the first occurrence of a substring from a string.

    Input
    {{ 'I really really like Jekyll' | remove_first: 'really' }}
    Output
    I really like Jekyll
  • replace

    Replaces any occurrence of a substring from a string.

    Input
    {{ 'I really really like Jekyll' | replace: 'really', 'truly' }}
    Output
    I truly truly like Jekyll
  • replace_first

    Replaces only the first occurrence of a substring from a string.

    Input
    {{ 'I really really like Jekyll' | replace_first: 'really', 'kinda' }}
    Output
    I kinda really like Jekyll
  • rstrip

    Removes whitespace characters from the end of a string.

    Input
    {{ '          I love Jekyll!          ' | rstrip }}
    Output
              I love Jekyll!
  • sassify

    Convert a Sass string into CSS output.

    Input
    // assigned to sass_code
    body
    color: #333
    // ignored comment
    background-color: yellow

    p
    /* fixed comment
    color: green
    {{ sass_code | sassify }}
    Output
    body {
    color: #333;
    background-color: yellow;
    }
    body p {
    /* fixed comment */
    color: green;
    }
  • scssify

    Convert a SCSS string into CSS output.

    Input
    // assigned to scss_code
    body {
    color: #333;
    // ignored comment
    background-color: yellow;

    p {
    /* fixed comment */
    color: green;
    }
    }
    {{ scss_code | sassify }}
    Output
    body {
    color: #333;
    background-color: yellow;
    }
    body p {
    /* fixed comment */
    color: green;
    }
  • size

    Return the size of a string.

    Input
    <!-- page.my_string is jekyll -->
    {{ page.my_string | size }}
    Output
    6
  • slice

    returns a substring, starting at the specified index.

    Input
    {{ "hello" | slice: 0 }}
    {{ "hello" | slice: 1 }}
    {{ "hello" | slice: 1, 3 }}
    {{ "hello" | slice: -2 }}
    {{ "hello" | slice: -3, 2 }}
    Output
    h
    e
    ell
    l
    ll
  • slugify

    Convert a string into a lowercase URL slug.

    Input
    {{ "The _config.yml file" | slugify }}
    Output
    the-config-yml-file

    The slugify filter accepts an option, each specifying what to filter. The default is default. They are as follows (with what they filter):

    • none: no characters
    • raw: spaces
    • default: spaces and non-alphanumeric characters
    • pretty: spaces and non-alphanumeric characters except for ._~!$&'()+,;=@
  • smartify

    Convert quotes into smart quotes with SmartyPants

    Input
    {{ 'Use "Jekyll" --- the static generator...' | smartify }}
    Output
    Use &ldquo;Jekyll&rdquo; &mdash; the static generator&hellip;
  • split

    Divide a string into an array.

    Input
    {{ "a~b" | split:"~" }}
    Output
    ['a', 'b']
  • strip

    Removes whitespace characters from around a string.

    Input
    {{ '          I love Jekyll!          ' | strip }}
    Output
    I love Jekyll!
  • strip_html

    Strip all html tags from the input string.

    Input
    {{ "<p>Jekyll is cool</p>" | strip_html }}
    Output
    Jekyll is cool
  • strip_newlines

    Strip all new line characters from the input string.

    Input
    {{ "Hello
    there"
    | strip_newlines }}
    Output
    Hello there
  • truncate

    Truncate a string down to x characters.

    Input
    {{ "I love Jekyll" | truncate: 12 }}
    {{ "I love Jekyll" | truncate: 12, " etc." }}
    Output
    I love Je...
    I love etc.
  • truncatewords

    Truncate string down to x words.

    Input
    {{ "I love Jekyll" | truncatewords: 2 }}
    Output
    I love...
  • upcase

    Converts a string to uppercase.

    Input
    {{ "static site generator" | upcase }}
    Output
    STATIC SITE GENERATOR
  • uri_escape

    URI escape a string.

    Input
    {{ "foo, bar \baz?" | uri_escape }}
    Output
    foo,%20bar%20%5Cbaz?
  • url_encode

    Encodes any characters unsafe for a URL.

    Input
    {{ "john@example.com" | url_encode }}
    Output
    john%40example.com
  • xml_escape

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

    Input
    {{ "<p>Hi Jekyll</p>"| xml_escape }}
    Output
    &amp;lt;p&amp;gt;Hi Jekyll&amp;lt;/p&amp;gt;

Liquid for loops Docs

  • else

    Condition when there are no items in the array.

    Input
    <!-- page.my_array is [] -->
    {% for item in page.my_array %}
    {{ item }}
    {% else %}
    There are no items!
    {% endfor %}
    Output
    There are no items!
  • first

    Returns whether it's the first iteration.

    Input
    <!-- page.my_array is [1, 2, 3] -->
    {% for item in page.my_array %}
    {% if forloop.first %}
    First!
    {% else %}
    Not first
    {% endif %}
    {% endfor %}
    Output
    First! Not first Not first
  • index

    index of the current iteration.

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {% for item in page.my_array %}
    {{ forloop.index }}
    {% endfor %}
    Output
    1 2 3
  • index0

    index of the current iteration (zero based).

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {% for item in page.my_array %}
    {{ forloop.index0 }}
    {% endfor %}
    Output
    0 1 2
  • last

    Returns whether it's the last iteration.

    Input
    <!-- page.my_array is [1, 2, 3] -->
    {% for item in page.my_array %}
    {% if forloop.last %}
    Last!
    {% else %}
    Not last
    {% endif %}
    {% endfor %}
    Output
    Not last Not last Last!
  • length

    Length of the entire loop.

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {% for item in page.my_array %}
    {{ forloop.length }}
    {% endfor %}
    Output
    3 3 3
  • limit

    Restrict how many items are looped through.

    Input
    <!-- page.my_array is [1, 2, 3, 4, 5] -->
    {% for item in page.my_array limit: 2 %}
    {{ item }}
    {% endfor %}
    Output
    1 2
  • offset

    Start looping from the nth item.

    Input
    <!-- page.my_array is [1, 2, 3, 4, 5] -->
    {% for item in page.my_array offset: 2 %}
    {{ item }}
    {% endfor %}
    Output
    3 4 5
  • reversed

    Reverses the order.

    Input
    <!-- page.my_array is [1, 2, 3, 4, 5] -->
    {% for item in page.my_array reversed %}
    {{ item }}
    {% endfor %}
    Output
    5 4 3 2 1
  • rindex

    Outputs the number of iterations left.

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {% for item in page.my_array %}
    {{ forloop.rindex }}
    {% endfor %}
    Output
    3 2 1
  • rindex0

    Outputs the number of iterations left (zero based).

    Input
    <!-- page.my_array is ['a', 'b', 'c'] -->
    {% for item in page.my_array %}
    {{ forloop.rindex0 }}
    {% endfor %}
    Output
    2 1 0

Liquid tags - control flow Docs

  • case

    Creates a switch statement to compare a variable with different values. `case` initializes the switch statement, and `when` compares its values.

    Input
    <!-- page.name is set to "home" -->
    {% case page.name %}
    {% when 'home' %}
    Home Page
    {% when 'about' %}
    About Page
    {% else %}
    Contact Page
    {% endcase %}
    Output
    Home Page
  • elsif

    Adds more conditions to an `if` or `unless` block.

    Input
    <!-- page.name is set to "contact" -->
    {% if page.name == 'about' %}
    About Page
    {% elsif page.name == 'contact' %}
    Contact Page
    {% else %}
    Other Page
    {% endif %}
    Output
    Contact Page
  • if

    Executes a block of code only if a certain condition is met.

    Input
    <!-- page.name is set to "about" -->
    {% if page.name == 'about' %}
    About Page
    {% endif %}
    Output
      About Page
  • operations

    Operators used in logic statements.

    • == equal
    • != not equal
    • > bigger than
    • < less than
    • >= bigger or equal
    • <= less or equal
    • or this or that
    • and must be this and that
    • contains includes the substring if used on a string, or element if used on an array
  • unless

    Similar to `if`, but executes a block of code only if a certain condition is **not** met.

    Input
    <!-- page.name is set to "about" -->
    {% unless page.name == "contact" %}
    It's not the contact page
    {% endunless %}
    Output
    It's not the contact page

    Which is the same as doing:

    {% if page.name != "contact" %}
    It's not the contact page
    {% endif %}

Liquid tags - iteration Docs

  • break

    Causes the loop to stop iterating.

    Input
    {% for i in (1..5) %}
    {% if i == 3 %}
    {% break %}
    {% else %}
    {{ i }}
    {% endif %}
    {% endfor %}
    Output
    1 2
  • continue

    Causes the loop to skip the current iteration.

    Input
    {% for i in (1..5) %}
    {% if i == 3 %}
    {% continue %}
    {% else %}
    {{ i }}
    {% endif %}
    {% endfor %}
    Output
    1 2 4 5
  • cycle

    Loops through a group of strings and outputs them in the order that they were passed as parameters.

    cycle must be used within a for loop block.

    Input
    {% for i in (1..5) %}
    {% cycle 'red', 'blue', 'yellow' %}
    {% endfor %}
    Output
    red blue yellow red blue
  • decrement

    Creates a new variable and every time it's called the value decreases by 1, with the initial value being -1.

    Input
    {% decrement my_variable %}
    {% decrement my_variable %}
    {% decrement my_variable %}
    Output
    -1
    -2
    -3

    Like increment, variables declared inside decrement are independent from variables created through assign or capture.

  • for

    Repeatedly executes a block of code.

    Input
    {% for page in site.pages %}
    {{ page.title }}
    {% endfor %}
    Output
    index
    about
    contact
  • increment

    Creates a new variable and every time it's called the value increases by 1, with the initial value being 0.

    Input
    {% increment my_variable %}
    {% increment my_variable %}
    {% increment my_variable %}
    Output
    0
    1
    2

    Variables created through the increment tag are independent from variables created through assign or capture.

    In the example below, my_var is created through assign. The increment tag is then used several times on a variable with the same name. However, note that the increment tag does not affect the value of my_var that was created through assign.

    Input
    {% assign my_var = 15 %}
    {% increment var %}
    {% increment var %}
    {% increment var %}
    {{ my_var }}
    Output
    0
    1
    2
    15

Liquid tags - other Docs

  • comment

    Don't output the contained text.

    Input
    My name is {% comment %}Mr{% endcomment %} Jekyll
    Output
    My name is Jekyll
  • highlight

    Code snippet highlighting.

    Input
    {% highlight ruby %}
    def foo
    puts 'foo'
    end
    {% endhighlight %}
    Output
    <div class="highlight">
    <pre><code class="language-ruby" data-lang="ruby"><span class="k">def</span> <span class="nf">foo</span>
    <span class="nb">puts</span> <span class="s1">&#39;foo&#39;</span>
    <span class="k">end</span></code></pre></div>
  • include

    Inserts a file from the `_includes` directory.

    Input
    <h1>My site</h1>
    {% include nav.html %}
    Output
    <h1>My Site</h1>
    <ul class="nav">
    <li><a href="/">Home</a></li>
    <li><a href="/about/">About</a></li>
    <li><a href="/contact/">Contact</a></li>
    </ul>
  • include_relative

    Includes a file relative to the current file.

    Input
    <h1>My site</h1>
    {% include_relative about.html %}
    Output
    <h1>My Site</h1>
    <h1>About</h1>
  • link

    Generate the correct permalink URL for the path you specify.

    Input
    {% link _collection/my-document.md %}
    {% link _posts/2017-03-15-my-post.md %}
    {% link blog/index.html %}
    {% link assets/document.pdf %}
    Output
    /my_collection/custom-permalink/my-document/
    /blog/my-post/
    /blog/
    /assets/document.pdf
  • post_url

    Generate the correct permalink URL for a post.

    Input
    {% post_url 2010-07-21-name-of-post %}
    Output
    /news/2010/07/21/name-of-post/
  • raw

    No liquid will be parsed in within these tags.

    Input
    {{ l_bracket}}% raw %{{ r_bracket }}
    {% raw %}{{ page.title }}
    {% endraw %}
    Output
    {{ page.title }}

Liquid tags - variable Docs

  • assign

    Create a new variable.

    Input
    {% assign my_variable = false %}
    {% if my_variable != true %}
    Hi there!
    {% endif %}
    Output
    Hi there!
  • capture

    Captures the string inside of the opening and closing tags and assigns it to a variable.

    Input
    {% capture my_variable %}
    Captured text.
    {% endcapture %}

    {{ my_variable }}
    Output
    Captured text.

Markdown Docs

  • blockquotes

    Input
    > Blockquotes are very handy in email to emulate reply text.
    > This line is part of the same quote.
    Output
    <blockquote>
    <p>Blockquotes are very handy in email to emulate reply text.
    This line is part of the same quote.</p>
    </blockquote>
  • code blocks

    Input
    ```
    def what?
    42
    end
    ```
    {: .language-ruby}
    Output
    <pre>
    <code class="language-ruby">
    def what?
    42
    end
    </code>
    </pre>
  • definition list

    Input
    HTML
    : Hypertext Markup Language, a standardized system for tagging text files.

    CSS
    : Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language
    Output
    <dl>
    <dt>HTML</dt>
    <dd>Hypertext Markup Language, a standardized system for tagging text files.</dd>
    <dt>CSS</dt>
    <dd>Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language</dd>
    </dl>
  • headings

    Input
    # H1

    ## H2

    ### H3

    #### H4

    ##### H5

    ###### H6
    Output
    <h1 id="h1">H1</h1>

    <h2 id="h2">H2</h2>

    <h3 id="h3">H3</h3>

    <h4 id="h4">H4</h4>

    <h5 id="h5">H5</h5>

    <h6 id="h6">H6</h6>
  • horizontal rules

    Input
    ---
    Output
    <hr />
  • lists

    Input
    1. First item
    2. Second item
    3. Third item

    * First item
    * Second item
    * Third item
    Output
    <ol>
    <li>First item</li>
    <li>Second item</li>
    <li>Third item</li>
    </ol>

    <ul>
    <li>First item</li>
    <li>Second item</li>
    <li>Third item</li>
    </ul>
  • paragraphs

    Input
    A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines
    Output
    <p>A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines</p>
  • tables

    Input
    | Tables        | Are           | Cool  |
    | ------------- |:-------------:| -----:|
    | col 3 is | right-aligned | $1600 |
    | col 2 is | centered | $12 |
    | zebra stripes | are neat | $1 |
    Output

    <table>
    <thead>
    <tr>
    <th>Tables</th>
    <th style="text-align: center">Are</th>
    <th style="text-align: right">Cool</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>col 3 is</td>
    <td style="text-align: center">right-aligned</td>
    <td style="text-align: right">$1600</td>
    </tr>
    <tr>
    <td>col 2 is</td>
    <td style="text-align: center">centered</td>
    <td style="text-align: right">$12</td>
    </tr>
    <tr>
    <td>zebra stripes</td>
    <td style="text-align: center">are neat</td>
    <td style="text-align: right">$1</td>
    </tr>
    </tbody>
    </table>
  • text markup

    Input
    **strong** text

    _emphasis_ text

    `inline` code

    [link](http://jekyllrb.com) text

    ![Alt tag](/path/to/image.jpg)
    Output
    <p><strong>strong</strong> text</p>

    <p><em>emphasis</em> text</p>

    <p><code>inline</code> code</p>

    <p><a href="http://jekyllrb.com">link</a> text</p>

    <p><img src="/path/to/image.jpg" alt="Alt tag" /></p>

Page variables Docs

  • path

    The path to the raw post or page.

    Input
    {{ page.path }}
    Output
    index.html
  • url

    The URL of the Post without the domain, but with a leading slash.

    Input
    {{ page.url }}
    Output
    /index.html

Post variables Docs

  • categories

    The list of categories to which this post belongs.

    Input
    <!-- tags is set to
    categories:
    - news
    -->

    {{ page.categories | array_to_sentence_string }}
    Output
    news
  • content

    The content of the post, rendered or un-rendered depending upon what Liquid is being processed and what `post` is.

    Input
    {{ page.content }}
    Output
    Hello World!
  • date

    The date assigned to the Post.

    Input
    {{ page.date }}
    Output
    2016-02-02 00:00:00 -0800
  • excerpt

    The un-rendered excerpt of the Post.

    Input
    {{ page.excerpt }}
    Output
    Hello World!
  • id

    An identifier unique to the Post.

    Input
    {{ page.id }}
    Output
    /2015/10/11/hello-world
  • next

    The next post relative to the position of the current post in `site.posts`. Returns `nil` for the last entry.

    Input
    {{ page.next.title }}
    Output
    /2016/01/02/hello-world.html
  • previous

    The previous post relative to the position of the current post in `site.posts`. Returns `nil` for the first entry.

    Input
    {{ page.previous.title }}
    Output
    /2016/01/02/im-fleeting.html
  • tags

    The list of tags to which this post belongs.

    Input
    <!-- tags is set to
    tags:
    - HTML
    - CSS
    -->

    {{ page.tags | array_to_sentence_string }}
    Output
    HTML and CSS
  • title

    The title of the post.

    Input
    {{ page.title }}
    Output
    Hello World

Site variables Docs

  • categories.category

    The list of all Posts in a category.

    Input
    {% for p in site.categories.news %}
    {{ p.url }}
    {% endfor %}
    Output
    /2016/01/03/goodbye-world.html
    /2016/01/01/hello-world.html
  • collections

    A list of all the collections.

    Input
    {{ site.collections | size }}
    Output
    1
  • configuration data

    All the variables set via the command line and your `_config.yml` are available through `site`.

    Input
    <!-- url is set to http://mysite.com in the configuration file -->
    {{ site.url }}
    Output
    http://mysite.com
  • data

    A list containing the data loaded from the YAML, JSON and CSV files located in the _data directory.

    Input
    {{ site.data.nba_players.first.name }}
    Output
    Michael Jordan
  • documents

    A list of all the documents in every collection.

    Input
    {{ site.documents | size }}
    Output
    19
  • html_pages

    A subset of `site.pages` listing those which end in `.html`

    Input
    {% for p in site.html_pages %}
    {{ p.path }}
    {% endfor %}
    Output
    about.html
    contact.html
    index.html
  • pages

    A list of all Pages.

    Input
    {% for p in site.pages %}
    {{ p.path }}
    {% endfor %}
    Output
    about.html
    contact.html
    index.html
    site-map.xml
  • posts

    A reverse chronological list of all Posts.

    Input
    {% for p in site.posts %}
    {{ p.url }}
    {% endfor %}
    Output
    /2016/01/03/goodbye-world.html
    /2016/01/02/im-fleeting.html
    /2016/01/01/hello-world.html
  • related_posts

    If the page being processed is a Post, this contains a list of up to ten related Posts. By default, these are the ten most recent posts.

    Input
    <!-- run on /_posts/2016-01-01-hello-world.md -->
    {% for p in site.related_posts %}
    {{ p.title }}
    {% endfor %}
    Output
    Goodbye World
    Im Fleeting
  • static_files

    A list of all static files (i.e. files not processed by Jekyll's converters or the Liquid renderer).

    Input
    {% for file in site.static_files %}
    {{ file.path }}
    {% endfor %}
    Output
    /css/style.css
    /js/my-script.js
  • tags.tag

    The list of all Posts with a particular tag.

    Input
    {% for p in site.tags.sad %}
    {{ p.url }}
    {% endfor %}
    Output
    /2016/01/03/goodbye-world.html
    /2016/01/02/im-fleeting.html
  • time

    The current time (when you run the jekyll command).

    Input
    {{ site.time }}
    Output
    2016-01-28 08:32:19 -0800

Static file variables Docs

  • extname

    The extension name for the file.

    Input
    {{ site.static_files.first.extname }}
    Output
    .css
  • modified_time

    The time the file was last modified.

    Input
    {{ site.static_files.first.modified_time }}
    Output
    1454000258
  • path

    The relative path to the file.

    Input
    {{ site.static_files.first.path }}
    Output
    /css/style.css

Yaml Docs

  • hashes

    Input
    # Nest hash
    my_hash:
    subkey:
    subsubkey1: 5
    subsubkey2: 6
    another:
    somethingelse: 'Important!'

    # Hash of hashes
    my_hash: {nr1: 5, nr2: 6}
  • sequences

    Input
    # sequence
    array:
    - 132
    - 2.434
    - 'abc'

    # sqeuence of sequences
    my_array:
    - [1, 2, 3]
    - [4, 5, 6]
  • variables

    Input
    a: 1
    b: 1.234
    c: 'abc'
    d: "abc"
    e: abc
    f: false # boolean type
    g: 2015-04-05 # date type

    # Enforcing strings
    h: !str 2015-04-05