Hugo 56, can't evaluate field Fill in type resource.Resource

After upgrading to Hugo .56, I get the following error when running a build:

ERROR 2019/07/27 11:33:45 render of "page" failed: "/Users/brunoamaral/Labs/Digital-Insanity/themes/now-ui/layouts/_default/baseof.html:115:17": execute of template failed: template: _default/single.html:115:17: executing "_default/single.html" at <.Fill>: can't evaluate field Fill in type resource.Resource

Looking at the code, this is what is causing the error:

<img class="img rounded" src="{{ with .Resources.GetMatch "header" }}{{ $image := .Fill "450x150" }}{{ $image.RelPermalink }}{{ end }}" alt="Story header: {{ .Params.title }}">```

I have tried to delete the resources directory, but that didn't work.

Isn’t what you get with the with a slice or array? I would have range inside of that with loop (if I would write it from scratch). The range dot then has .Fill available.

It might be possible that you can’t use with in connection with a resource slice. The documentation uses it only outside of loops (see https://gohugo.io/content-management/image-processing/#image-processing-examples) with assignments (first line). So this might be code that doesn’t throw errors:

{{ $original := .Resources.GetMatch "header" }}
{{ .Scratch.Set "image" ($original.Fill "450x150") }}
{{ $image := .Scratch.Get "image" }}
...
{{ with $image }}{{ .RelPermalink }}{{ end }}
...

Edit: It appears that my issue with with might be related to yours. (with $.Param "something.subkey" stopped working) Something definitely changed here: https://discourse.gohugo.io/t/access-to-param-subkey-stopped-working-in-0-56-0

Maybe even a bug? @bep?

I’m also getting a similar errors on two different projects after upgrading to 0.56.

ERROR 2019/07/27 07:37:28 render of "page" failed: "/Users/projects/layouts/_default/single.html:21:31": execute of template failed: template: _default/single.html:21:31: executing "main" at <.Resize>: can't evaluate field Resize in type resource.Resource

I opened an issue in Github about this. I don’t know enough but my feeling is that this is a bug.

1 Like

I assume the “nil” issue reported above is related to this:

I will look into that and issue a (new) patch release tomorrow.

thanks @bep ! :slight_smile:

Unfortunately (for you, anway) my issue was a mistake I did when moving the Hugo theme to a module, and not with Hugo itself. I have added a better error message for my situation to help others …

That said,

If your nil issue persists in Hugo 0.56.1, I would guess that you have a non-image file named … header something.

Thanks @bep.

There were indeed some empty header params, and it didn’t stop there.

I had to rename files from .JPG to .jpg in order for the build to work. I still need to run more tests but it seems fixed.