Cheat sheet

Start Jekyll

bundle exec jekyll serve --watch

metadata variables

foo: bar

Let's make a reference to [%foo]

Let’s make a reference to bar

Dev versus Production


    <!-- Use to show DISQUS (for example) comments only in production. -->
    {% if site.production %}
        <!-- prod stuff -->
    {% endif %}
    <!-- Developing a local only feature not ready for production. -->
    {% unless site.production %}
        <!-- local stuff -->
    {% endunless %}

Footnotes

Here is some text containing a footnote[^somesamplefootnote]. You can then continue your thought...

[^somesamplefootnote]: Here is the text of the footnote itself.

or

This is an example of an inline footnote.[^This is the *actual* footnote.]

or

Let's cite a fake book.[p. 42][#fake]

[#fake]: John Doe. *A Totally Fake Book*. Vanity Press, 2006.

del, insert, mark

This is {--is --}a test.

This is {–is –}a test.

This {++is ++}a test.

This {++is ++}a test.

This {~~isn't~>is~~} a test.

This {~~isn’t~>is~~} a test.

This is a {==test==}.

This is a {==test==}.

Paths


	{% post_url 2010-07-21-name-of-post %}

Path to images

Put images in /_assets/images/ then:


    <img src="{% asset_path thierry.jpg %}" alt="Thierry" />

Or (image markup):


![My helpful screenshot]({% asset_path thierry.jpg %})

#

Returns encoded Base64 data URI. Use it to embed images into your stylesheets:

asset_data_uri(asset_logical_name)

Returns URL of compiled asset:

asset_path(asset_logical_name)

Put extra assets and pages under:

/extras/<post slug (without date)>/

Then link to those images/pages/etc. via:


{% extras_path image.png %}

Excerpts

Completely disable it by including this in front-formatter:

excerpt_separator: ""

Include

    {% include rail.html %}

Pass parameters to an Include

{% include footer.html param="value" %}

These parameters are available via Liquid in the include:

{{ include.param }}

Write number of words

{{ page.content | number_of_words }}

kill jekyll:

	$ ps aux | grep jekyll
	$ kill -9 PID

or

    $ lsof -wni tcp:4000
    $ kill -9 PID

Write keys from an array


    {% for post in site.posts %}
      <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
    {% endfor %}


    {% for tag in page.tags %}
      <li> <a href="{{ page.tag }}">{{ page.tag }}</a></li>
    {% endfor %}

The list of all Posts with tag TAG.


    {{ site.tags.TAG }}

Array of tags

    tags: [one, two, three]

Plain HTML in YAML

example: >
        HTML goes into YAML without modification
message: |

        <blockquote style="font: italic 12pt Times">
        <p>"Three is always greater than two,
           even for large values of two"</p>
        <p>--Author Unknown</p>
        </blockquote>
date: 2007-06-01

Post excerpt

    {{ post.excerpt }}

Code highlighting

linenos is optional


    {% highlight css linenos %}
    body { foo: bar;}
    {% endhighlight %}


    permalink: /:title/


    <a href="{{ post.url }}">Read Post</a>

Tweet stuff

Check _config.yml

Tweet:


    {% tweet https://twitter.com/DEVOPS_BORAT/statuses/159849628819402752 %}

Suggested tweet:


    {% suggested_tweet %}

And:


    {{ site.suggested_tweet.text }}

Gist

Use the gist tag to easily embed a GitHub Gist onto your site:


    {% gist 5555251 %}

Result:

<script src="https://gist.github.com/5555251.js"> </script>

You may also optionally specify the filename in the gist to display:


    {% gist 5555251 result.md %}

Result:

<script src="https://gist.github.com/5555251.js?file=result.md"> </script>

The gist tag also works with private gists, which require the gist owner’s github username:


    {% gist parkr/931c1c8d465a04042403 %}

Result:

<script src="https://gist.github.com/parkr/931c1c8d465a04042403.js"> </script>