Getting started

lesson 6. Add a blog

Every website has a news section or a blog. That is why are going to add a ‘posts’ directory to our content folder. In this new directory we create a markdown file named ‘’, which is our first post. This file should look like this:

title: Hello world
date: 2016-02-01 10:00:00
This is my first blog post

The date should be the current date. The time is optional. Additionally we are going to add a (new) layout file for our blog overview (a list view of our posts). Hugo requires you to name this file ’list.html’ and store it in the ‘_default’ directory. This file looks like this:

{{ partial "header.html" . }}
    {{ range .RegularPages }}
            {{ if .Date }}{{ .Date | time.Format ":date_long" }}{{ end }}
            <h2>{{ .Title }}</h2>
            <p>{{ .Summary }}... <a href="{{ .RelPermalink }}">Read more</a></p>
    {{ end }}
{{ partial "footer.html" . }}

You can additionally update your ‘single.html’ in the ‘_defaults’ directory and add the ‘.Date’ parameter. It should then look something like this:

{{ partial "header.html" . }}
    {{ if .Date }}{{ .Date | time.Format ":date_long" }}{{ end }}
    <h1>{{ .Title }}</h1>
    {{ .Content }}
{{ partial "footer.html" . }}

This will make sure your posts (single pages) also show the date of the post. Your project should now looks like this: