@Paloma Your issue ultimately appears to be your level of understanding of the file format (md
- markdown) and the template language (Go
templates) that you’re working with.
It can be difficult to determine the cause of issues, but if you run your build locally and find the issue is occurring there, then it’s a good indication that it’s not Netlify specific.
Seeking assistance in the best-fit place, this question could have been directed to the Hugo community, as it’s ultimately their tooling that you’re encountering confusion with.
As I mentioned in another thread, I don’t work with Hugo myself and don’t want to install it, so I can’t test my assumptions from reading their documentation, but I think your issue/solution are…
You have an array of images defined as:
gallery:
- image: https://res.cloudinary.com/dwpmwj4ba/image/upload/v1668535441/projects/Ayax%20y%20Prok/DREAMBEACH-3_zfwdjh.jpg
You’re then trying to show it in your template with:
{{ range .Params.gallery }}
<li class="projects__gallery-list-slide">
<img src="{{ . }}">
</li>
{{ end }}
Checking the Hugo documentation for “the dot”, it indicates that it represents the current context, and that inside an iteration it will contain the current item from the loop.
You’re inserting the item directly into the src
as if it is a string, however the way you have it defined in the markdown, the item on the first loop, would be:
image: https://res.cloudinary.com/dwpmwj4ba/image/upload/v1668535441/projects/Ayax%20y%20Prok/DREAMBEACH-3_zfwdjh.jpg
However that isn’t a string, it’s an object, where your string is stored on a key of image
.
So you likely want to either:
- Change your array definition in the markdown
FROM
---------
gallery:
- image: https://res.cloudinary.com/...
- image: https://res.cloudinary.com/...
Which is the equivalent of
[
{ image: 'https://res.cloudinary.com/...' },
{ image: 'https://res.cloudinary.com/...' }
]
TO
---------
gallery:
- https://res.cloudinary.com/...
- https://res.cloudinary.com/...
Which is the equivalent of
[
'https://res.cloudinary.com/...',
'https://res.cloudinary.com/...'
]
OR
-
Access the image
key on the context
within your template output
{{ range .Params.gallery }}
<li class="projects__gallery-list-slide">
<img src="{{ .image }}">
</li>
{{ end }}