serhii.net

In the middle of the desert you can say anything you want

09 Feb 2022

Hugo sorting posts by filename

If I write multiple posts per day, their order within that day looks wrong. This is because in their frontmatter each has a date but no time.

date: 2022-02-09

This is done so on obyde’s side, not something I want to change.

Solution?

Use the Zettelkasten-filenames of the actual .md files.1 I wanted them like this for better ordering visually on my local filesystem, why not take advantage of this.

Solution by SO2:

{{ range sort site.RegularPages "File.Path" }}
  {{ . }}
{{ end }}

  1. I’m now writing inside 220209-2209 Hugo sorting posts by filename ↩︎

  2. templates - How to order content by FilePath in Hugo? - Stack Overflow ↩︎

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus