Sorting by publish date, but revert date when pubdate absent

Having a hard time figuring out how to address an issue I’m having. I display my last 10 most recent blog posts on my site & in my RSS feed… pretty standard. Some pages use the publishDate property, others don’t. What I’m seeing is that the date property is used in the sorting, but publishDate isn’t used.

What I’d like is to have the most recent say: sort by publishDate in descending order, but when publishDate isn’t present, use date. Is that possible?

Here’s what I currently have…everything I’ve tried so far keeps erroring out… ideas?

{{ range first 10 (where .Site.RegularPages "Section" "blog") }}
{{ partial "blog-list-item" . }}
{{ end }}

I haven’t tried this myself, but I think it’s possible. Hugo can configure dates in several ways.

You could use that feature to tell Hugo to use publishDate and, when that one is not present, fall back on date.

I think you then have to sort by publish date, and that Hugo will automatically fill in the missing publication dates with the date value.

Good luck! :slight_smile: