I’m trying to sort through two things at once: pagination, and GroupByDate. I imported a bazillion posts from an old weblog and am trying to reconstruct a weekly or monthly view of archives.
The snippet I have now reads
{{ range .Data.Pages.GroupByDate "2 January 2006" }}
<h2>{{ .Key }}</h2>
{{ range .Pages }}
<h3><a href="{{ .Permalink }}">{{ .Title }}</a></h3>
{{ .Content }}
{{ end }}
{{ end }}
which nicely groups by date. However with a bazillion posts the front page gets too big, so I need to paginate.
The built-in paginator in Hugo doesn’t currently support PagesGroup (the return value from .Data.Pages.GroupByDate). It shouldn’t be hard to support that, but someone would have to do some work (please open a issue at GitHub).
It should, however, be possible to use the current paginator with .Data.Pages and similar, and do the grouping “by hand”.
This reply is very related, but if you would like me to start a new thread, I can.
I’m trying to create a view so that when someone navigates to http://localhost:1313/2015 they can see all posts in that year, and same with http://localhost:1313/2015/01/ they can see all posts made in Jan 2015.
Note: http://localhost:1313/2015/01/test-post/ does render the proper post, but there are no “index.html” files in the 2015 or 01 folders.
I’ve read and reread the following pages on gohugo.io:
It seems as though I need to create something like this, but it doesn’t work.
/layouts/2015/2015.html
/layouts/2015/01/01.html
from the example blog, they have /layouts/indexes/post.html which I don’t understand entirely, nor does it really do what I’m trying to do. What’s special about the indexes folder name, I can’t find that in the documentation.
With the following in place, I successful get an index.html file in at urls /2015/ and /2015/02/, and with the debug print, it will allow me to continue development and refine these pages.
so, config.yaml is fairly easy to implement, 1 taxonomy per year, the post generation (to include the year/mo taxonomy) could probably done with archetypes?
@Weston_McNamee Thanks for this solution. Adding the taxonomies might work and it’s not a lot of but I would prefer native support from Hugo. Sounds like a feature request, or not?
I came up with an alternative solution that solves the permalink problem (creating index.html for /2015, /2015/08, etc) using sections rather than taxonomies. See this post on my blog for details.