Some days ago Johnny posted about Jekyll and that motivated us (Martin and me) to perform some spikes with it. So in this post I will share what I have been doing. I assume that you have already set up your Ruby environment.
Let’s start by installing jekyll:
$> sudo gem install jekyll
Very easy and straightforward.
Now create a directory for your site and create the following files/folders in it (this structure is basically what Jekyll’s documentation suggests):
- _config.yml, this file stores the configuration data that is used by Jekyll. Most of this information can assume default values or the values can be specified as command line arguments when invoking Jekyll. I suggest specifying the destination argument, which specifies where output files will be placed.
- index.html, this will be the landing page of your site, but in order for this file to be processed by jekyll we need to add the following line at the top of the file. This will indicate to jekyll which layout to use in order to render the page as well as its title.
--- layout: default title: jekyll-spike ---
- _layout, as you may imagine this folder will contain the files that define the layout of your pages (in .net we would say the “master pages”)
- _post, this folder is where you will place the markdown files with your posts
That is pretty much all; now you can add the classic folders for static resources like images, css, etc.
Now to generate your website, just open a terminal in the root directory of your application and call jekyll
This will create a whole static site under the folder you specified as the destination in the _config.yml file. Now, every time you want to add a new post/page, just create a markdown file under the _posts folder and then execute jekyll to regenerate the site.ust ese
There is also an option in jekyll to generate the site and start a webserver to host the site all at once, just execute
$> jekyll --server
Well this is all for now. If you want, you can download a zip file with this basic structure from here.