Monthly archive pages for blog

How would I build the typical monthly archive pages in Hugo? See http://kottke.org/everfresh for an example. Basically grouping all posts by content type and their published month + year, then generating a list page for them.

I can’t find a way to do this in the docs but it is a pretty basic feature. Maybe the real question is, what is the plan regarding custom list page templates?

Sorry in advance if I just missed the relevant docs. :\

Hugo has support for this in the form of taxonomies. Taxonomies allow you to create any type of grouping you want to. While it does require a single extra field in the front matter, it is certainly simpler than any other solution.

Thanks spf for the tip :), thought I think it could be a very useful feature to provide this kind of grouping out of the box :).

Some kind of example would be nice. I’m not finding the documentation on taxonomy’s quick to parse.

I’d also like monthly and yearly archives, and I don’t think taxonomies are the best way to do so.

Could we have a way to generate archive pages for each year (with URL like http://mysite.com/2015) and for each month (http://mysite.com/2015/06) ?

1 Like

If I recall I got this technique looking at @spf13’s site repo (thanks!), but I’m doing it via a section template, showing posts grouped by years on my blog top instead of just a list of posts.

The section page result is here:

http://rick.cogley.info/post/

And the template is here:

It’s not exactly what you want perhaps, but this was good enough for me. I did not see a need to have it in the sidebar a la Wordpress or whatever. YMMV. Perhaps it’ll spark an idea for you.

2 Likes

Thanks for your answer ! It’s interesting, but it has to be done manually.

It’s not really necessary for me either, but it’s handy to go back and see what was published that year or month.

my pleasure

1 Like

I figured out a solution to this problem by leveraging taxonomies. See this post.

note: this is a full solution, not a workaround. It creates an index.html at urls /year/ and /year/month/.