I have this project structure after running hugo new
and adding minimal working files:
project
│ config.yaml
│
└───layouts
│ │ index.html
│ │
│ └───_default
│ │ baseof.html
│
│ └───layouts
│ │ head.html
│ │ recent.html
│ │ script-footer.html
│
└───content
│ └───posts
│ │ └───2022-10-31
│ │ │ index.md
│ │ └───2023-05-28
│ │ │ index.md
│ │ └───2023-05-28 copy
│ │ │ index.md
│
md:title=layouts/partials/recent.html
<div>
<hr class="solid">
{{ $bydate := (where .Site.Pages "Section" "posts") }}
{{ range sort $bydate ".Params.start" }}
{{ $dateTime := .Params.start }}
{{ $title := .Params.title}}
{{ if $dateTime }}
<div>
<p style="font-size:12px">
<time datetime="{{ $dateTime }}">{{ $dateTime | time.Format ":date_long" }}</time>
<t/>
{{ $title }}
</p>
</div>
{{end}}
{{end}}
<hr class="solid">
</div>
md:title=content/posts/2022-10-31/index.md
---
draft: false
title: "Summer"
start: "2022-10-31T00:00:00+11:00"
---
md:title=content/posts/2023-05-28/index.md
---
draft: false
title: "Depth"
start: "2023-05-28T00:00:00+11:00"
---
md:title=content/posts/2023-05-28 copy/index.md
---
draft: false
title: "Summer"
start: "2023-05-28T00:00:00+11:00"
---
This results in the following screenshot:
I expected both list items “2023-05-28T00:00:00+11:00” to sort at the same level (they don’t?!). If the Dates are being treated as Strings they should still sort together. I tried these combinations that do not work:
--- {{ range sort $bydate ".Params.start" }}
+++ {{ range sort $bydate (time ".Params.start") }}
+++ {{ range sort $bydate (".Params.start" | time) }}