Range page resources in order

I have a list of resource images in my front matter and i want to range over them exactly as they are ordered. I am using {{ range .Resources.ByType “images” }}, but the problem is, it is picking resources directly from my folder and not from the front-matter. Is there a way to do this?

By default Resources order is alphanumeric based on their filename.

You can either sort them by weight, see this topic for an example.


Use the :counter placeholder at the start of the resources .Name and sort them like so:

{{- range sort (.Resources.ByType "image") "Name" -}}
{{- end -}}
1 Like

This has been a huge help. Thank you. :slightly_smiling_face:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.