Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Jekyll: A Ruby-Powered Static Site Generator

By Ric Roberts / November 5, 2009

jekyllJekyll is a simple Ruby-powered static site generator, originally by Tom Preston-Werner (aka mojombo) of Github fame. It's focused around blogging, but it can be configured to generate any kind of static site. (Note: Jekyll has been around for about a year - Tom originally blogged about it in November last year, so apologies if this is old news to some readers, but I've only recently discovered it!)

Because Jekyll outputs a static site structure, it means you can host your blog (or site) from anywhere that you can serve static HTML, simply by using your favourite web server (e.g. Apache). As Tom describes in his blog post, the idea came from wanting to be able to "Blog like a Hacker". Jekyll lets you write from the comfort of your favourite text editor, and publish from the command line. Using familiar tools reduces the cognitive load involved with publishing a blog, and lets you focus on what you're writing. It doesn't hurt that even a pretty weak Web server could stand a pounding if it's just serving static files!

By default, Jekyll uses its own (slightly modified) flavour of Liquid templates, with help from pygments for syntax highlighting, and you can use textile or markdown for the content. Each Jekyll blog article template needs a header containing some metadata about that article, such as what layout to use, the article's title, and any custom information you want to provide (such as tags for that article).

Generating your site is easy: just running the jekyll command turns your directory of templates into a complete website, ready to serve. There's a Jekyll server that you can use for testing (passing --auto as an argument means it will automatically regenerate the site when things are changed).

jekyll --server --auto

Github Pages provides a neat way to publish your Jekyll-generated site. Every Github page is actually run through Jekyll when you push content to your pages repo (this works because a normal static site is also a valid Jekyll site).

The easiest way to get started with Jekyll is by installing the gem (which is available on Gemcutter), and checking out the wiki on Github, where there's some great documentation.

sudo gem install jekyll

As you might expect, Tom Preson-Werner's personal blog runs on Jekyll. Its source is publicly available on Github.

Comments

  1. Sam Soffes says:

    Jekyll is awesome. I've been using it for a couple of weeks with great success on GitHub Pages. It's definitely worth checking out. The Jekyll wiki has a lot of great blogs done in Jekyll that are open source on GitHub to learn from.

  2. Nick Quaranto says:

    There's plenty of sites running on Jekyll, if you need more examples to get started. http://wiki.github.com/mojombo/jekyll/sites

  3. rs says:

    On top of Github pages, you can host your Jekyll sites on XP-Dev.com as well:

    http://docs.xp-dev.com/user-guide/directfilehosting.html

  4. Fabio Cevasco says:

    It is kinda old news indeed, and the idea of Ruby-powered static site generators is hardly new itself. I counted *fourteen* different ones!

    Jekyll is nice, mainly because it's integrated with GitHub pages, but personally I think nanoc (http://nanoc.stoneship.org/) is more mature and FAR more flexible. I recently moved my web site from Typo to nanoc and I didn't regret it -- just the ability to have custom metadata to associate to pages in nanoc made it worthwhile. Here's how I did it: http://www.h3rald.com/articles/take-back-your-site-with-nanoc/

  5. Sasa Brankovic says:

    > just the ability to have custom metadata to associate to pages in nanoc made it worthwhile.

    You can associate metadata with posts in Jekyll too, so it's no different than Nanoc in that regard. In fact it's done in the same way (mixing YAML and post content).

  6. Stuart Ellis says:

    I suspect that Jekyll is going to become the defacto standard static site generator, thanks to the GitHub association and name recognition. I've been happily using Webby (http://webby.rubyforge.org) for a while now, having switched from Nanoc. It supports all of the features mentioned, and has a nice Rails flavor, but doesn't seem to be talked about much.

  7. Peter Cooper says:

    @Stuart: Agreed. Or.. as the Ruby way seems to be, we'll all be raving over some other new system within three months and Jekyll will be viewed as old hat. I only wish I were joking.. :-)

  8. Matt says:

    staticmatic: http://staticmatic.rubyforge.org/
    has also been around for quite a while, as another way to do this kind of thing in ruby.

  9. George Ornbo says:

    I moved my blog over to Jekyll after experimenting with a a little site on GitHub pages. As it is essentially text files it makes version control simple and there are all the benefits of serving just an HTML site. There are converters for anyone moving from the major blogging engines.

    I haven't used any of the other Ruby based static site generators but I'm sold.

  10. Włodek Bzyl says:

    I would like to join this discussion as lately
    I have personally witnessed how powerful Jekyl is.

    During one of my lectures I told my students to
    replace their notebooks with blog.
    I prepared a simple template for Jekyll and presented
    it to prove that having a blog is easy and fun.

    The results exceeded my expectations.
    They can be seen here: http://github.com/popular/forked
    under "jBlog" (currently 175 forks %-).

  11. Matt Buck says:

    I'm in the process of moving my blog to Middleman, a new entry into the Ruby-static-site-generator scene. The biggest motivator for me was the built-in haml and sass support, but it's got a ton of other great stuff. Check it out: http://github.com/tdreyno/middleman/

  12. Sumit says:

    How To Make demon thread for the application

    -d option is not working

Other Posts to Enjoy

Twitter Mentions