gohugoio/hugo ยท error
no layout given
Error message
no layout given
What it means
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.
Source
Thrown at hugolib/page__per_output.go:109
renderHooks *renderHooks
}
func (pco *pageContentOutput) trackDependency(idp identity.IdentityProvider) {
pco.po.p.dependencyManagerOutput.AddIdentity(idp.GetIdentity())
}
func (pco *pageContentOutput) Reset() {
if pco == nil {
return
}
pco.contentRenderedVersion++
pco.contentRendered.Store(false)
pco.renderHooks = &renderHooks{}
}
func (pco *pageContentOutput) Render(ctx context.Context, layout ...string) (template.HTML, error) {
if len(layout) == 0 {
return "", errors.New("no layout given")
}
templ, found, err := pco.po.p.resolveTemplate(layout...)
if err != nil {
return "", pco.po.p.wrapError(err)
}
if !found {
return "", fmt.Errorf("template %q not found", layout[0])
}
// Make sure to send the *pageState and not the *pageContentOutput to the template.
res, err := executeToString(ctx, pco.po.p.s.GetTemplateStore(), templ, pco.po.p)
if err != nil {
return "", pco.po.p.wrapError(fmt.Errorf("failed to execute template %s: %w", templ.Name(), err))
}
return template.HTML(res), nil
}
View on GitHub (pinned to 8a468df065)
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 }}`.
Example fix
<!-- before -->
{{ range .Pages }}{{ .Render }}{{ end }}
<!-- after -->
{{ range .Pages }}{{ .Render "summary" }}{{ end }} Defensive patterns
Strategy: validation
Validate before calling
// Site author: ensure a layout exists for every kind/output format you enable // e.g. layouts/page.html, layouts/list.html, layouts/home.html, layouts/baseof.html
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- template %q not found
- failed to execute template %s: %w
- error building site: %w
- failed to detect format from content
- failed to detect target data serialization format
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/862361408ffd66dd.json.
Report an issue: GitHub.