Learn Jekyll Really Quick

  Posted on 26 Jun 2015

This article is helping you learn the basics of Jekyll and setup your blog right now. The boring minutiaes which can easily learned when you use it is not mentioned at all.

What is it?

Jekyll is a software allowing you to setup and manage your blog with some HTML templates and snippets and nothing else.


Here is an easy example to show the basic usage of Jekyll.

I suggest you star it on GitHub, unless you can remember it forever. You can fork or download it to work on it.


Following is the file structure of the example.

|  +snappit.ext
|  +2013-01-01-title1.html
|  +2013-01-01-title2.html
|  +default.html
+--index.html It uses Liquid language to generate the pages. The "_site" directory contains the generated website.

#YAML Heads

We can see that nearly every file have something like the following in their heads.

layout: default
title: my post

They are called YAML. This defines some properties of the files for us to load when use them in jekyll projects.

You can define some properties of the project by writing YAML in “_config.yml”.


In the directory of “_layouts” are some HTML template files. They all have the keyword {{ content }}. It marks where the content of the file using the layout is to be inserted. You can write “layout: layout_file_name” in the YAML to set the layout of the file. Actually, the layout_file_name is a path and name relative to the directory of “_layouts”.


In the directory of “_includes” are some “*.ext” files. They are the HTML snippets to include in other files. Use the following code to insert the snippets.

{% include file_name.ext %} The file name is actually a path and name relative to the directory of "_includes".


In the directory of “_posts” are the articles in the blog. They can be written in HTML. Their names must be in the format of “yyyy-mm-dd-name.html”.


We need to include the list of our posts in “index.html” by the following code.

{% for post in site.posts %}
<a href="{{post.url}}">{{ post.title }}</a>Posted on {{ post.date | date_to_string }}
{% endfor %}

This is a loop generating the title and link of each post. We can have multiple HTML files or directories in this directory, just like a normal website’s structure including CSS and JavaScript. They will all be proceeded just like the index.

Build Command

In linux operating system, first cd to the directory contains the jekyll project. Then, type in the following command. Finally, check “” in your browser. The index will be displayed.

jekyll serve