Can't iterate over a list of .Params trying to make thumbnails for posts

I have the following list.html (list of all my pages):

{{ define "main" }}
    <main class="posts">
        <h1>{{ .Title }}</h1>

        {{- if .Content }}
            <div class="content">{{ .Content }}</div>
        {{- end }}

        {{- range .Data.Pages.GroupByDate "2006" }}
            <div class="posts-group">
                <div class="post-year">{{ .Key }}</div>

                <ul class="posts-list">
                    {{- range .Pages }}
                        <li class="post-item">
                            <a href="{{.Permalink}}">
                                {{- $image := resources.Get .Params.featured_image -}}
                                {{ printf "%#v" $image }}
                                {{with $image}}
                                <img src="{{ ($image.Fill "200x200 q100 Center").RelPermalink }}">
                                {{end}}
                                <span class="post-title">{{.Title}}</span>
                                <!-- Removing this so the date doesn't render 
                                <span class="post-day">{{ if .Site.Params.dateformShort }}{{ .Date.Format .Site.Params.dateformShort }}{{ else }}{{ .Date.Format "Jan 2"}}{{ end }}</span>
                                -->
                            </a>
                        </li>
                    {{- end }}
                </ul>
            </div>
        {{- end }}
    </main>
{{ end }}

In the <li class="post-item"> section I want to print small thumbnails but it gives me a <nil> pointer for every item on the list. I have added a

featured_image: "/media/test.png"

in all my markdown files. I don’t understand what I am doing wrong… I have stored the test image in the /content/media folder - or is that wrong? Please help me, thanks!

Oh, figured it out myself. Hugo is looking in the assets folder of the theme when calling resources.Get. I put a symbolic link to my actual media folder there and now all is jolly!

1 Like

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