Create several pages from one list template

I’m trying to create a specific layout for the blog on my site-- it should list all of the current month’s posts on the landing page for the /blog section. At the bottom of that landing page, I want a list of links to 1) all the previous months for the current year, and 2) all the previous years. In the latter case, only one link for each previous year exists. Following a year link takes the user to the page that represents the last month of that year.

All pages have the same layout-- selected month’s blog posts at the top, followed by other months’ blog posts, followed by other years’ blog posts-- but the layout would generate a number of static pages, depending on the number of blog posts. Is this possible with Hugo? Can someone show me how I might accomplish this?

Thanks!

Not saying this could or could not be done, but have you read the documentation? I would expect more specific questions from someone who did.

Would you consider your response helpful?

As a starting point, it sounds like you need to range through dates of posts, which Hugo creates for you in the front matter of content.

Check out the docs on templating and see what you can do.

Yes. You ask too much in your “question”, which is more like “read and understand this, then build the site for me”. We may have given the false impression that this is how good the Hugo support is.

But if this isn’t clear in the doc, we should spend that time making the Hugo doc better – so this forum isn’t the first stop for every question about Hugo.

1 Like