I want users to be able to upload images that will be shown in the site footer. I’m trying to configure config.yml to store a list of these images. This works:
and the supporter_logos folder has md files created with the correct front matter. But how would I get the images into my footer since readDir only gives me FileInfo objects. How would I access the front matter variables? Seems like this should be data, so I’ve tried storing in data as yml:
You’d probably get better help and faster responses regarding this on Hugo’s forums (discourse.gohugo.io) since there are a lot of skilled people who have an amazing knowledge about this application.
Oh, it’s the config for Netlify CMS? I have never used it personally, so had no idea. Yeah, then it might be difficult to get help there. But you can keep it posted there too. Till then if someone here has got experience with this kind of a setup, they can help.
Another place to look for help is in the CMS maintainers chat - they can guide you as to whether this is a bug or feature request, for instance:
I’m with @hrishikesh that the hugo community may/may not be able to answer. Certainly we are friends, but many there do not use Netlify and will probably push you back towards here…
I figured out the best way to do this. It was to store the list of supporter logo in a yml file within the data folder by adding a section to the config.yml:
Then, in the footer (or anywhere) it’s easy to access that data by declaring a variable:
{{ $data := index .Site.Data .Site.Language.Lang }}
Then loop through them with e.g:
{{ range $data.supporters.items }}
<a href="{{ .url }}">
<img src="{{ .logo }}" alt="" style="width:120px;"/>
</a>
{{ end }}