gohugoio/hugo · error
%s: Resource.Err was removed in Hugo v0.141.0 and replaced w
Error message
%s: Resource.Err was removed in Hugo v0.141.0 and replaced with a new try keyword, see https://gohugo.io/functions/go-template/try/
What it means
A template accessed `.Err` on a resource.Resource value, a field that was removed in Hugo v0.141.0. Hugo detects the generic template failure 'can't evaluate field Err in type resource.Resource' during render and rewrites it into this actionable message pointing at the replacement `try` keyword for error handling on resources.GetRemote and similar.
Source
Thrown at hugolib/hugo_sites_build.go:416
// render renders the sites.
func (h *HugoSites) render(l logg.LevelLogger, config *BuildCfg) error {
l = l.WithField("step", "render")
start := time.Now()
defer func() {
loggers.TimeTrackf(l, start, h.buildCounters.loggFields(), "")
}()
siteRenderContext := &siteRenderContext{cfg: config, infol: l, multihost: h.Configs.IsMultihost}
renderErr := func(err error) error {
if err == nil {
return nil
}
// In Hugo 0.141.0 we replaced the special error handling for resources.GetRemote
// with the more general try.
if strings.Contains(err.Error(), "can't evaluate field Err in type") {
if strings.Contains(err.Error(), "resource.Resource") {
return fmt.Errorf("%s: Resource.Err was removed in Hugo v0.141.0 and replaced with a new try keyword, see https://gohugo.io/functions/go-template/try/", err)
} else if strings.Contains(err.Error(), "template.HTML") {
return fmt.Errorf("%s: the return type of transform.ToMath was changed in Hugo v0.141.0 and the error handling replaced with a new try keyword, see https://gohugo.io/functions/go-template/try/", err)
}
}
return err
}
i := 0
for s := range h.allSites(nil) {
if s.conf.Segments.Config.SegmentFilter.ShouldExcludeCoarse(segments.SegmentQuery{Site: s.siteVector}) {
l.Logf("skip site %s not matching segments set in --renderSegments", s.resolveDimensionNames())
continue
}
siteRenderContext.languageIdx = s.siteVector.Language()
h.currentSite = s
for siteOutIdx, renderFormat := range s.renderFormats {
if s.conf.Segments.Config.SegmentFilter.ShouldExcludeCoarse(segments.SegmentQuery{Output: renderFormat.Name, Site: s.siteVector}) {View on GitHub ↗ (pinned to 8a468df065)
Solutions
- Rewrite the template to use try: `{{ with try (resources.GetRemote $url) }}{{ with .Err }}error{{ else with .Value }}use it{{ end }}{{ end }}` — see https://gohugo.io/functions/go-template/try/.
- Update the theme to a version that supports Hugo ≥0.141.0.
- As a stopgap, pin Hugo to <0.141.0 until templates are migrated.
Example fix
{{/* before (Hugo < 0.141) */}}
{{ with resources.GetRemote $url }}
{{ with .Err }}{{ errorf "%s" . }}{{ else }}{{ .Content }}{{ end }}
{{ end }}
{{/* after (Hugo >= 0.141) */}}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}{{ errorf "%s" . }}{{ else with .Value }}{{ .Content }}{{ end }}
{{ end }} Defensive patterns
Strategy: validation
Validate before calling
# find removed Resource.Err usages before upgrading past v0.141.0 grep -rn '\.Err\b' layouts/ | grep -i resources
Try / catch
{{/* replace .Err checks with try */}}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}{{ warnf "%s" . }}{{ else }}{{ with .Value }}...{{ end }}{{ end }}
{{ end }} Prevention
- Before upgrading to Hugo ≥ v0.141.0, grep templates for Resource.Err and migrate to the try keyword
- Read the release notes for removed template APIs on every minor upgrade
- Pin the Hugo version in CI and upgrade deliberately with a template audit
When it happens
Trigger: Rendering a template containing patterns like `{{ with resources.GetRemote $url }}{{ with .Err }}...{{ end }}{{ end }}` (the pre-0.141 idiom for handling remote fetch errors) on Hugo ≥0.141.0.
Common situations: Upgrading Hugo past 0.141.0 with an older theme or copied snippet that used `.Err` to guard resources.GetRemote failures; themes not yet updated for the try keyword.
Related errors
- %s: the return type of transform.ToMath was changed in Hugo
- no Key set in Resource
- resources.PostProcess cannot be used in a deferred template
- no Resource provided in transformation
- type %T not supported in Resource transformations
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/d3b9c83350b57a43.json.
Report an issue: GitHub ↗.