HUGO

GroupByDate "2006"

{{ range .RegularPages.ByDate.Reverse }}
{{- partial “session-card.html” . -}}
{{ end }}
I want to group session as follows;
year (2001)
session-1
session-2

year (2000)
session-1
session-2

each session has
date = 2020-04-24T14:36:15-06:100:

I am new to Hugo,
Could not run a loop using scratch. what is best way to do this?

By year:

{{- range .RegularPages.GroupByDate "2006" -}}
<h2>{{ .Key }}</h2>
  {{ range .Pages }}
    <h3><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
    <p>{{ .Summary }}</p>
    {{- if .Truncated -}}
      <p><a href="{{ .RelPermalink }}">Continue reading...</a></p>
    {{- end -}}
  {{- end -}}
{{- end -}}
1 Like

such a simple and elegant… Hugo is powerful, thanks alot. :slight_smile: