Articles

Pages and posts in Jekyll

What are pages and posts for Jekyll? The differences between these two items.


Part 1 | Part 2 | Part 3

This is the 2nd part of a series of articles about Jekyll, a blog aware static website creation tool. During the first part I’ve presented the quick startup to create a minimal autogenerated website using Jekyll.

Inside the _layouts folder of an automatically generated by Jekyll website we can find three files: default.html, page.html and post.html. The first one is the general layout for every page in the site, the second one is specific for normal pages while the third is specific for posts (articles whose pages will be automatically created and handled) inside the _posts folder.

The main difference between a page and a post is that a page will need to be explicitly created outside of the _posts folder and it will be served as it was created, if you create a page called /about.html then your site at http://localhost:4000/about.html will serve such page.

A post page instead must be created inside the _posts folder with a date-title filename, like 2014-06-29-welcome-to-jekyll.markdown and it will be served as http://localhost:4000/category/subcategory/year/month/day/title/index.html.

In the Jekyll’s vision the pages should be used for general information pages, like index, abouts, legals or links pages. The posts are useful to handle the web content as a blog, when a new item (post) is published a new page will be added to the contents, under a predictable structure.

Both these two rules can be customized using a directive called permalink but the above is the default behavior for newly created pages or posts.