Getting Started with Jekyll
In rebuilding this site I made the move to Jekyll, an excellent static site generator. Everything went swimmingly when I found what I was looking for, but the finding seemed a bit more difficult than I expected. Maybe I missed a key resource, but I'll outline what I did to hopefully save someone a bit of time. You can also browse this site's repository and others for more examples.
Getting Started
A few things to note, Jekyll gives the following special consideration:
_config.yml
— file, stores site settings, you can see mine here, and all options in the wiki._site
— by default this is where Jekyll generates the static version of the site, you can override this in the _config.yml_posts
— directory, where Jekyll looks here for blog posts_layouts
— directory, contains your layout files.{{content}}
tag in the layout is where the main body of content from your individual pages will be inserted.
Page Settings
At the top of each page you'll see the bits of information Jekyll uses when constructing the site, here is a sample for one of my blog posts:
---
layout: default
title: Git
categories: jekyll
published: true
---
These should be self explanatory, but lets run through them real quick:
layout
should correspond to a file in _layouts and is required for any file that is going to be generated using a template,title
blog post title,categories
blog post categories,published
a boolean, regarding weather to publish the post.
You can also add custom attributes here, which you can call from the template using {{page.attribute_name}}
Iterating Over Posts
In my index.html file, I have:
{% for post in site.posts limit:5 %}
{{ post.content }}
{% endfor %}
You can add more advanced options in the wiki. See the Pagination along with the Post sections for respective information.
Setting Your Permalink Style
You'll on the bottom of each of my post pages, you'll notice a call to {post.url}. This is generated form a combination of two factors. Jekyll can parse the date of the post from its file name, you'll notice anything in my _posts directory is named in the DD-MM-YYYY-post_title.html format. In my _config.yml file you'll see a line similar to:
permalink: /blog/:year/:month/:day/:title
Jekyll will parse this information out of the filename when creating the permalinks and blog directory.