Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a page to render permalink in Hugo

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?

like image 351
Mark Dee Avatar asked Nov 08 '22 04:11

Mark Dee


1 Answers

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

like image 151
Skrylar Avatar answered Nov 15 '22 07:11

Skrylar