{"id":"862361408ffd66dd","repo":"gohugoio/hugo","slug":"no-layout-given","errorCode":null,"errorMessage":"no layout given","messagePattern":"no layout given","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page__per_output.go","lineNumber":109,"sourceCode":"\trenderHooks *renderHooks\n}\n\nfunc (pco *pageContentOutput) trackDependency(idp identity.IdentityProvider) {\n\tpco.po.p.dependencyManagerOutput.AddIdentity(idp.GetIdentity())\n}\n\nfunc (pco *pageContentOutput) Reset() {\n\tif pco == nil {\n\t\treturn\n\t}\n\tpco.contentRenderedVersion++\n\tpco.contentRendered.Store(false)\n\tpco.renderHooks = &renderHooks{}\n}\n\nfunc (pco *pageContentOutput) Render(ctx context.Context, layout ...string) (template.HTML, error) {\n\tif len(layout) == 0 {\n\t\treturn \"\", errors.New(\"no layout given\")\n\t}\n\ttempl, found, err := pco.po.p.resolveTemplate(layout...)\n\tif err != nil {\n\t\treturn \"\", pco.po.p.wrapError(err)\n\t}\n\n\tif !found {\n\t\treturn \"\", fmt.Errorf(\"template %q not found\", layout[0])\n\t}\n\n\t// Make sure to send the *pageState and not the *pageContentOutput to the template.\n\tres, err := executeToString(ctx, pco.po.p.s.GetTemplateStore(), templ, pco.po.p)\n\tif err != nil {\n\t\treturn \"\", pco.po.p.wrapError(fmt.Errorf(\"failed to execute template %s: %w\", templ.Name(), err))\n\t}\n\treturn template.HTML(res), nil\n}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/page__per_output.go#L91-L127","documentation":"Returned by pageContentOutput.Render when it is called with zero layout names. This method backs the template function `.Render` on a Page (e.g. `{{ .Render \"summary\" }}`), which renders the page through a named layout; with no layout name there is nothing to resolve, so Hugo fails immediately instead of guessing a default.","triggerScenarios":"Calling `.Render` in a template with no argument (`{{ .Render }}`) or with a variable that evaluates to an empty argument list; programmatic calls to pageContentOutput.Render(ctx) with an empty layout slice.","commonSituations":"Theme templates that call `{{ .Render }}` expecting default behavior like `.Content`, refactors that dropped the layout argument, or passing an unset variable as the layout name in list templates iterating pages.","solutions":["Pass a layout name: `{{ .Render \"summary\" }}` (which resolves e.g. layouts/summary.html for the page).","If you just want the rendered content, use `{{ .Content }}` instead of `.Render`.","If the layout name comes from a variable/param, guard it: `{{ with $layout }}{{ $.Render . }}{{ end }}`."],"exampleFix":"<!-- before -->\n{{ range .Pages }}{{ .Render }}{{ end }}\n<!-- after -->\n{{ range .Pages }}{{ .Render \"summary\" }}{{ end }}","handlingStrategy":"validation","validationCode":"// Site author: ensure a layout exists for every kind/output format you enable\n// e.g. layouts/page.html, layouts/list.html, layouts/home.html, layouts/baseof.html","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provide templates for every page kind and output format you enable (page, section, home, taxonomy, term)","When adding custom output formats, add matching layout files or they render with no layout","Run hugo --printPathWarnings / verbose build locally to catch missing layouts before deploy"],"tags":["hugo","templates","render","layouts"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}