Range with numbered filenames need Natural Sort Order

{{- range $index, $image := .Resources.ByType "image" -}}

With this range on images with numbered filenames like
i-1.jpg
i-2.jpg
i-10.jpg

I get a default sorting like
i-1.jpg
i-10.jpg
i-2.jpg

How to get a Natural Sort Order like the first list?

You name your files in natural order.

you’re right. simplest solution.

As an added note, you can rename the resources and use a counter etc. (there should be docs about this), but for the natural sort you currently need to do that on the disk.

Yes, there are docs on the use of counter.

Though, I would just name the files as 00-foo, 01-foo, etc. if I needed natural sort.

Well, this is not a solution. What if he gets to 100? Should he rename everything? No.

1 Like

Completely agree - this isn’t even a reasonable workaround.

Could we pre-pad the incoming range with zeroes somehow? I’m really new to Hugo and to Go, so I’m not sure what this would look like.

See if this cannot help: https://gohugo.io/content-management/page-resources/#the-counter-placeholder-in-name-and-title