wikimatze |

Why I use Jekyll for blogging

Posted by @wikimatze on Jun 02, 2011

I always wanted blogging for several years and tried many things different plattforms wordpress, blogger, tumblr. The main problem which kept me away from writing was just the fact, that every time I want to write I just had to do it in a new environment in a certain gui and not in my favorite editor vim. Every system gives me the freedom to extend it in several ways but in the end it didn’t provide me the freedom to change every tiny peace I want. With jekyll I can use my favorite text editor and it really “turned me into a text monster”. This description sounds like a holy grail, but let me explain in the following sections why it is so great.

What jekyll is

Jekyll is a static site generator written in ruby to generate html pages. The page is presented through several templates and then fires the whole site were articles are written text markup language like Textile or Markdown though the liquid converters to generate fully generated compiled website. Don’t think that it will be so easy for you to do it. First of all you have to learn either Textile or Markdown. I chose textile for writing my posts because I use Markdown to create the README files for my github accounts.

Setting up the environment

You need to have a valid ruby and ruby gems installation on your machine. A simple gem install jekyll will install all the following mentioned gems:

To get nice syntax highlighting for your code you have to install pygments via sudo apt-get install python-pygments on Ubuntu/Debian. On install page you can get more information about how to setup jekyll.

The directories and styles

Here is the basic layout of a typical jekyll project:

Other files can just put on the root directory like an atom.xml file (for RSS feed) or 404.html page. For example has my post.html the following layout:

The lines between - mark a special Yaml Front Matter file. This block is treated as a special block in jekyll and can contain different components. The { {content} } stands for the content of a post entry.

Creating a layout

Here is the main template for my blog.

I used the meta-language Sass to create my CSS. There is one problem with Sass: You have to compile it every time you made a change. Fortunately there is the compass gem which always compiles my sass file when I change it. When I build my page I start with compass watch css/ & a command to automate Sass building. This is very handy when I change the layout.

Static webpages – how to include dynamic content

Jekyll creates only static webpages but with the help of Javascript it is possible to add a Disqus comment platform. You just have to create an account and then use the following snippet:

It is best to put this piece of code in a extra file under your _includes directory and then add it in your template for posts. Now the comment function is available in all your posts.

Deployment

There is a bunch of deployment strategies: rsync, ftp, Rack-Jekyll (deploy on Heroku, EC2, etc.). I prefer ftp (with the glynn gem) because it was easy to install and worked great with my server configuration in my _config.yml.

Conclusion

Just look on other pages what is possible with Jekyll. You can learn many new things by looking at other jekyll blogs and copy what you need. I love it write a little bit and after I finished an article just perform rake deploy to upload my blog.

Tweet this post
blog comments powered by Disqus