Hugo: Weighted Page Resources
For a page file index.md
with front matter that specifies individual resources with a custom parameter weight
:
---
resources:
- src: "infux6hmtq901.jpg"
title: Source Image - Shiba Inu (Japanese Dog Breed) with a leaf mane
params:
weight: 1
- src: "narnia lion 1080.jpg"
params:
weight: 10
- src: doge-real-lion.jpg
params:
weight: 20
- src: Shiba Inu Dog with leaf mane multiple.jpg
title: Seamless tile for seamless, endless repetition
params:
weight: 30
- src: Shiba Inu Dog with leaf mane tile span 1080p.jpg
title: Proof of the seamless tile
params:
weight: 40
- src: Shiba Inu Dog with leaf mane.png
title: Cutout
params:
weight: 30
- src: "*"
params:
weight: 99
---
For the page layout:
{{with .Resources.ByType "image"}}
<div class="images-showcase">
{{range sort (.) "Params.weight"}}
<figure>
<img src="{{.RelPermalink}}">
<figcaption>{{.Title}}</figcaption>
</figure>
{{end}}
</div>
{{else}}
No images added yet…
{{end}}