Can't evaluate field Err in type resource.Resource

How to correct the error?

{{- $data := "" }}
{{- $URL := "https://example.com/test.json" }}
{{- with resources.GetRemote $URL }}
  {{- with .Err }}
    {{- errorf "%s" . }}
  {{- else }}
    {{- $data = . | transform.Unmarshal }}
  {{- end }}
{{- else }}
  {{- errorf "Unable to get remote resource %q" $URL }}
{{- end -}}
$ hugo env
hugo v0.141.0-e7bd51698e5c3778a86003018702b1a7dcb9559a+extended linux/amd64 BuildDate=2025-01-16T13:11:18Z VendorInfo=gohugoio
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.23.4"
github.com/sass/libsass="3.6.6"
github.com/webmproject/libwebp="v1.3.2"

See https://gohugo.io/functions/resources/getremote/ (use try as shown).

what do you think of adding a pointer at the beginning of the GetRemote docs page. something like

new in 0.141.1

from 141 you have to use with try to capture erros. see details → try page

Please don’t be offended, but I dislike stuff like that because it ages… we need to remember (and be motivated) to remove it later.

I’ll see about modifying our “new-in” shortcode so that it accepts content. That shortcode throws a warning after a certain number of releases, reminding us to remove it.

1 Like

i like that interpretation of my something like

2 Likes

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