List pages in a section by year, then by author and print author's list of pages

Hi,

I’d like to achive this list in a section template (I have ‘date’ (date is not year but 2006-01-01 format) and ‘author’ in front matter).

  • 2019
    • bob
      • pageA
      • pageB
    • helen
      • pageX
      • pageY
  • 2020
    • joe:
      • pageC
      • pageD

The problem is I have no idea how to do complex query. If I would NOT want to group pages by author, I would use GroupByDate but here I’m lost.

You can nest your range statements, so something like

<ul>
{{ range $pages.GroupByDate "2006" }}
    <li>
    {{ .Key }}
    <ul>
        {{ range .Pages.GroupByParam "author" }}
            <li>{{ .Title }}</li>
        {{ end }}
    </ul>
    </li>
{{ end }}
</ul>

Thanks a lot. The 2006 is format specification for date or is that a parameter for GroupByDate “filter”? If the latter, can I get all years dynamically?

That’s the date format, so this tells it to group by year. Each iteration will be the list of pages for that year.

An easy readable documentation of Golang’s weird date formatting is here:

I always wondered what the history is behind this numbered way, never saw it in another programming language.