Group content by week number of year

I want to summarize my posts weekly, so I want to write a archetype template to auto find out pages of latest week and put into a new pages.

I found this may be useful: but I didn’t found the right format of week number of date.

I have tried below code according to return format.

{{ range .Site.Pages.GroupByDate "2006 50" }}
## {{ .Key }}
{{ end }}

But won’t work.

I tried to code an example to this but couldn’t. Hugo simply doesn’t recognise weeknumbers (as you already pointed out), which of course makes sense because based on the source I looked at, Go doesn’t either.

There’s still a workaround, however. If you add the weeknumber to the front matter of each post, you can use that value as a key to group by. Of course, that’s not great since it’s a hassle to figure out the weeknumber and to ensure you always provide it in a post.

Sorry for not being more helpful. :hugs:

How about calculating week start/end dates in an array and walking through that, comparing against publishdate?

You might have to create the list of dates separately but I’m sure there are lots of tools that could create a JSON data file for you.

Thanks for trying. I thought about add weeknumber to front matter, but it’s not convenience, neither organize manually, I don’t have to deal with lots of files each week for now, so I decided to organize by hand now.