Image processing works locally but fails on netlify

I have just introduced image processing in my theme and, locally, it appears to work perfectly.

However, on updating my repo, netlify fails to build.

My local environment:
hugo v0.101.0+extended linux/amd64 BuildDate=unknown
GOOS=“linux”
GOARCH=“amd64”
GOVERSION=“go1.18.3”

I assume that the issue is bad practice on my part and that netlify is using a less forgiving version of hugo?

Perhaps, I could construct this code in a way that plays well with both versions?

{{ with $thispost := . }}
 {{ with .Resources.GetMatch .Params.image }}
  {{ with .Resize "600x webp" }}
    <a href="{{ $thispost.RelPermalink }}" class="image-side" style="background-image:url({{ .RelPermalink }}); display:block; min-height:250px; background-size:cover; background-position: center;"></a>
  {{ end }}
 {{ end }}
{{ end }}

Netlify tells me this:

1:54:28 PM: Start building sites …
1:54:28 PM: hugo v0.85.0-724D5DB5+extended linux/amd64 BuildDate=2021-07-05T10:46:28Z VendorInfo=gohugoio
1:54:28 PM: ERROR 2022/08/02 12:54:28 render of "taxonomy" failed: "/opt/build/repo/themes/outlearn/layouts/_default/list.html:33:37": execute of template failed: template: _default/list.html:33:37: executing "main" at <.Params.image>: invalid value; expected string
1:54:28 PM: ERROR 2022/08/02 12:54:28 render of "taxonomy" failed: "/opt/build/repo/themes/outlearn/layouts/_default/list.html:33:37": execute of template failed: template: _default/list.html:33:37: executing "main" at <.Params.image>: invalid value; expected string
1:54:28 PM: Error: Error building site: failed to render pages: render of "taxonomy" failed: "/opt/build/repo/themes/outlearn/layouts/categories/list.html:34:36": execute of template failed: template: categories/list.html:34:36: executing "main" at <.Params.image>: invalid value; expected string
1:54:28 PM: Total in 429 ms
1 Like

But why your local is 0.101 and on hosting end you using 0.85.

On Netlify you decide what version need to be used.

Check your declaration on Netlify.toml file

1 Like

@idarek Thank you for pointing that out. It appears I was missing that file.

I have added the netlify.toml file and the site builds correctly.

2 Likes

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