For quite a while now, I am using Hugo to display my photographic work. I built a theme which treats posts as galleries, and a gallery (post) can contain images. This nearly perfectly suits my needs for https://kaiser.gallery
Metadata (date and title) is being read from the EXIF tags, which is fine for my needs. However some people might like to manually add those information to the images without changing the files (or overriding existing EXIF tags).
Recently I learned about Page resources metadata, so I added the possibility to read metadata (in this case the image title) from there:
---
date: 2024-02-18T14:12:44+0100
title: Cats
featured_image: cat-8.jpg
resources:
- src: cat-1.jpg
title: Brown tabby cat on white stairs
- src: cat-2.jpg
title: Selective focus photography of orange and white cat on brown table
---
Currently, as can be seen in the above front matter, the “featured image” (the album cover, used for lists, etc.) is set as featured_image
.
Would it (from a “make it the Hugo way” perspective) make sense to also move this information to the resources
node?
---
date: 2024-02-18T14:12:44+0100
title: Cats
- featured_image: cat-2.jpg
resources:
- src: cat-1.jpg
title: Brown tabby cat on white stairs
- src: cat-2.jpg
title: Selective focus photography of orange and white cat on brown table
+ params:
+ cover: true
---
The theme would then take the first image with “Params.cover=true” as album cover.
Does this make more sense than directly referencing the cover image as featured_image
?
I saw multiple approaches to this in different themes, many just take the first image or the first with *feature*
in its name. However for my theme I’d like to be able to directly reference a cover image instead of relying on the file name.
What do you think?