{"record":{"id":"862361408ffd66dd","repo":"gohugoio/hugo","slug":"no-layout-given","errorCode":null,"errorMessage":"no layout given","messagePattern":"no layout given","errorType":"validation","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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/page__per_output.go#L91-L127","documentation":"Thrown by pageContentOutput.Render in hugolib/page__per_output.go:109 when the variadic layout argument is empty. Render needs at least one layout/view name to look up the template to execute; with none it cannot proceed. This is the engine behind the .Render and .RenderShortcodes template methods.","triggerScenarios":"Calling {{ .Render }} (or .RenderString) in a template without passing a layout name, or invoking page.Render(ctx) with no layout arguments in Go. Also triggered when a shortcode/template delegates to .Render with a variable that resolves to an empty string.","commonSituations":"Forgetting the view argument in a baseof/block template, passing an unset page param as the layout name (e.g. {{ .Render .Params.view }} when view is blank), or refactoring a layout lookup and dropping the argument.","solutions":["Pass a concrete layout/view name, e.g. {{ .Render \"summary\" }} which resolves to layouts/_default/summary.html.","If the layout name comes from a param, guard it: {{ with .Params.view }}{{ $.Render . }}{{ end }}.","Verify the layout file exists under layouts/ (e.g. layouts/page.html or layouts/_default/<view>.html) after fixing the call."],"exampleFix":"// before\n{{ .Render }}\n// after\n{{ .Render \"summary\" }}","handlingStrategy":"validation","validationCode":"// In a Go template, guard the layout name before calling Render.\n{{ with .Params.view }}{{ $.Render . }}{{ else }}{{ $.Render \"default\" }}{{ end }}","typeGuard":"// Go callers: ensure at least one layout arg is present.\nfunc hasLayout(layout ...string) bool { return len(layout) > 0 && layout[0] != \"\" }","tryCatchPattern":null,"preventionTips":["Always pass a literal or validated layout name to .Render.","Lint templates for bare {{ .Render }} calls.","When the layout comes from params, default to a known view if empty."],"tags":["template","rendering","layout"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}