How to create a page to render permalink in Hugo

1.6k views Asked by At

I followed this tutorial in Hugo and its working fine. Basically I have the following content:

- content
  `- post
     `- coding
        `- html
           `- my-post.md

and my config file set to

[permalinks]
  post = "/:year/:month/:title/"

which gives me the URL

http://example.com/2016/12/my-post/

What I want is for readers to see a list of post based on a date or year. For example if they visit http://example.com/2016/12/ they will see a list of post published in December. If they visit http://example.com/2016/ they will see a list of post published in 2016.

Is there any way to do that in Hugo?

1

There are 1 answers

0
Skrylar On

The easiest way to do this was found on the Hugo forums, and the answer is to use a Taxonomy for every year. Each post needs to be placed in to that year's taxonomy and a custom listing template is used to generate the pages. This will allow Hugo to create an index page for each "year" (taxonomy) where the entries are the "month." It's a creative solution, although more cumbersome than one would like.

https://discuss.gohugo.io/t/pagination-and-group-by-date/1441