In order to add a new post to your site, just create a new file within the
_posts directory with a suitable file extension, by default that should be
Naming conventions are important and so you should make sure to give it a file name with a structure like
YYYY-MM-DD-my-first-post.md, similar to the example posts you can already tinker with.
Jekyll will order your articles by the date included in the file name, so it’s required that you choose a file name which follows this convention exactly.
Each file which shall be processed by Jekyll needs to start with so called front-matter which provides some kind of configuration to the processor, so it will be able to render each page properly.
Essentially, front-matter is written in YAML and starts and ends with three dashes followed by the posts content itself.
- layout: The layout will be always
default so don’t think about it too much and feel free to copy and paste it into the front-matter area of each post.
- title: The title will be what you can see on top of each page as well as in the overview on the homepage.
- type: The type defines the format of each page — you can choose between
home, but we’ll use
post for now.
Please feel free to have a look at the existing posts and pages shipped with this theme in order to get an idea how it works.
Now that the configuration has been done, just write some Markdown below the second line of dashes, hit save, open up your terminal or console again and enter
jekyll build once again to generate the output.
Nobody likes to enter the
jekyll build command manually all of the time. In fact,
jekyll build is just the most basic command it offers and let me say it as it is, it’s definitely not the most convenient solution.
For example, there’s an option which watches your folder for changes and automatically builds the new site for you immediately. Once again, please have a closer look at the Jekyll documentation for further details.
In general, pages work more or less just like posts — in fact, they even share the same front-matter.
The only difference might be the layout, because pages usually don’t have next or previous pages and so there’s no teaser at the bottom obviously and comments are just available for posts, but aside from that, they’re pretty much identical.
In order to create a page instead of a post, please create a new file in the root of this theme and add a file extension such as
.markdown, depending on your own preference.
Considering that it’s a static page and not a sequence of posts, we don’t need a date in its file name anymore and so it could look like this for example:
Add just the same front-matter, but instead of setting
post, it should be
page this time. Rebuild the site once again via
jekyll build or a more advanced command and that’s it already!