{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/site.go#L1734-L1770","documentation":"Wrapped by Site.renderForTemplate (hugolib/site.go:1752) when executing a layout template for a page or standalone output (sitemap, RSS, 404, etc.) fails. The %q is the page path or template name, and %w carries the actual template execution error. Note that a nil template is not this error — that's silently logged as a missing layout.","triggerScenarios":"ExecuteWithContext failing on any layout render: layouts/page.html, layouts/list.html, taxonomy/term templates, sitemap/robots/404 renders — due to template runtime errors (nil pointer method calls, failing template funcs, errorf calls, bad .Params access).","commonSituations":"Theme templates broken by a Hugo upgrade (removed methods like .Site.Author), templates assuming site/page params that a given page lacks, partial or render-hook errors bubbling up, or data files missing keys the template indexes into.","solutions":["Inspect the wrapped error — it identifies the template file and line of the real failure.","Guard optional params/resources in the template with `with`/`if` before dereferencing.","If the failing name is a specific page, compare its front matter to pages that render fine.","After a Hugo upgrade, update the theme or check release notes for removed template APIs."],"exampleFix":"// before (layouts/page.html)\n{{ .Params.author.name }}\n// after\n{{ with .Params.author }}{{ .name }}{{ end }}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := site.Build(...); err != nil {\n    // \"render of %q failed: %w\" — unwrap to find the template error\n    var te *herrors.ErrorContext\n    log.Printf(\"render failed: %v\", err)\n    // do not publish partial output; fail the deploy\n    return err\n}","preventionTips":["Treat any build error as fatal in CI; never deploy the partially rendered publishDir","Test custom templates with representative content before rolling them out","Unwrap the error chain to identify which page and template failed, then fix the template"],"tags":["hugo","template","rendering","layout"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}