{"record":{"id":"13435823de3f40e6","repo":"gohugoio/hugo","slug":"render-of-q-failed-w","errorCode":null,"errorMessage":"render of %q failed: %w","messagePattern":"render of %q failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/site.go","lineNumber":1752,"sourceCode":"\treturn false\n}\n\nfunc (s *Site) renderForTemplate(ctx context.Context, name, outputFormat string, d any, w io.Writer, templ *tplimpl.TemplInfo) (err error) {\n\tif templ == nil {\n\t\ts.logMissingLayout(name, \"\", \"\", outputFormat)\n\t\treturn nil\n\t}\n\n\tif ctx == nil {\n\t\tpanic(\"nil context\")\n\t}\n\n\tif err = s.GetTemplateStore().ExecuteWithContext(ctx, templ, w, d); err != nil {\n\t\tfilename := name\n\t\tif p, ok := d.(*pageState); ok {\n\t\t\tfilename = p.String()\n\t\t}\n\t\treturn fmt.Errorf(\"render of %q failed: %w\", filename, err)\n\t}\n\treturn\n}\n\nfunc (s *Site) shouldBuild(p page.Page) bool {\n\tif !s.conf.IsKindEnabled(p.Kind()) {\n\t\treturn false\n\t}\n\treturn shouldBuild(s.Conf.BuildFuture(), s.Conf.BuildExpired(),\n\t\ts.Conf.BuildDrafts(), p.Draft(), p.PublishDate(), p.ExpiryDate())\n}\n\nfunc shouldBuild(buildFuture bool, buildExpired bool, buildDrafts bool, Draft bool,\n\tpublishDate time.Time, expiryDate time.Time,\n) bool {\n\tif !(buildDrafts || !Draft) {\n\t\treturn false\n\t}","sourceCodeStart":1734,"sourceCodeEnd":1770,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/site.go#L1734-L1770","documentation":"Executing a layout template for a page or output format failed. site.renderForTemplate calls GetTemplateStore().ExecuteWithContext (site.go:1747) and, on error, wraps it with the page/render target name via %w. The underlying cause is a Go template runtime error inside the layout.","triggerScenarios":"A layout (e.g. layouts/page.html, layouts/_default/list.html) calls a function/method that errors: nil dereference, undefined function, wrong argument types, or a partial that itself errors. The %q filename is the page path when d is a *pageState, otherwise the layout name.","commonSituations":"Upgrading Hugo and using a removed/renamed template function; a layout referencing .Site.Data fields that no longer exist after a content restructure; a partial missing; output-format-specific layout calling an unsupported method.","solutions":["Inspect the wrapped error after 'render of \"...\" failed:' to get the precise template/runtime cause.","Open the named layout and find the offending call (the error usually names the function or line).","Add defensive {{ with }}/{{ if }} guards around optional values and conditional output-format branches.","Confirm all referenced partials exist and the template uses Hugo's current API."],"exampleFix":"// before (layout)\n<title>{{ .Title }} - {{ .Site.Params.brand.name }}</title>\n\n// after\n<title>{{ .Title }}{{ with .Site.Params.brand }} - {{ .name }}{{ end }}</title>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Layouts run inside Hugo's render pipeline; use {{ with }} guards and errorf.\n{{ with .Site.Params.brand }}\n  <title>{{ $.Title }} - {{ .name }}</title>\n{{ else }}\n  {{ errorf \"layout %q: .Site.Params.brand not configured\" $.Layout }}\n{{ end }}","preventionTips":["Guard optional site/page values in layouts with {{ with }}/{{ if }}.","Keep layouts aligned with the current Hugo template API after upgrades.","Use {{ errorf }} to surface explicit messages instead of opaque runtime errors."],"tags":["template","rendering","layout","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}