Page resource metadata

How would I define and access gallery front matter data that includes each image (in a page bundle), alt text, and image caption? Thanks!

content structure

content/
├── posts/
│   ├── post-1/
│   │   ├── images/
│   │   │   ├── a.jpg
│   │   │   └── b.jpg
│   │   └── index.md
│   └── _index.md
└── _index.md

content/posts/post-1/index.md

+++
title = 'Post 1'
date = 2023-01-01T00:00:00-00:00
draft = false
[[resources]]
  src = 'images/a.jpg'
  title = 'A kitten!'
  [resources.params]
    alt = 'Photograph of a black kitten'
[[resources]]
  src = 'images/b.jpg'
  title = 'Another kitten!'
  [resources.params]
    alt = 'Photograph of a grey kitten'  
+++

layouts/_default/single.html

{{ range .Resources }}
  <figure>
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="{{ .Params.alt }}">
    <figcaption>{{ .Title }}</figcaption>
  </figure>
{{ end }}

https://gohugo.io/methods/resource/params/

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