Creating a blog

Adding a blog to your site is as simple as adding a post.

To create a new post, you can create a new markdown file inside the _posts directory by following the recommended file naming format:

YEAR-MONTH-DAY-title.MARKUP

Where YEAR is a four-digit number, MONTH and DAY are both two-digit numbers, and MARKUP is the file extension representing the format used in the file. For example, the following are examples of valid post filenames:

2020-12-31-new-years-eve-is-awesome.md
2019-09-12-how-to-write-a-blog.md

Post requires front matter, everything in between the first and second — are part of the YAML Front Matter, and everything after the second — will be rendered with Markdown and show up as “Content”. The following is a post file with different configurations you can add as example:

---
layout: post
title: How To Travel On Low Budget
---

Articles index

Adding a post will make it available on your site. If you create a post 2020-12-31-new-years-eve-is-awesome.md will make it available in your browser with this location: /2020/12/31/new-years-eve-is-awesome/.

What you often see is article index pages, like /blog/ which contain the five latest blog entries. You can add the following code to an /blog/index.md page to do this:


{%for post in site.posts%}

# {{post.title}}

{{post.excerpt}}

[Read more]({{ post.url | relative_url }})
{%endfor%}

This should iterate over all your posts and show them on the page.

To keep things more organized, add post images to /assets/posts/ directory, and add theme images to /assets/images/ directory.


Adding pages to your site
Data files