gohugoio/hugo · error

render: %w

Error message

render: %w

What it means

Sent via SendError when the render() step fails. Rendering applies templates to assembled pages and writes output; the %w is the rendering error (template execution, output write, image processing, etc.).

Source

Thrown at hugolib/hugo_sites_build.go:198

			h.reportProgress(func() (state terminal.ProgressState, progress float64) {
				return terminal.ProgressNormal, 0.20
			})

			return nil
		}

		if prepareErr = prepare(); prepareErr != nil {
			h.SendError(prepareErr)
		}
	}

	for s := range h.allSites(nil) {
		s.state = siteStateReady
	}

	if prepareErr == nil {
		if err := h.render(infol, conf); err != nil {
			h.SendError(fmt.Errorf("render: %w", err))
		}

		// Make sure to write any build stats to disk first so it's available
		// to the post processors.
		if err := h.writeBuildStats(); err != nil {
			return err
		}

		// We need to do this before render deferred.
		if err := h.printPathWarningsOnce(); err != nil {
			h.SendError(fmt.Errorf("printPathWarnings: %w", err))
		}

		if err := h.renderDeferred(infol); err != nil {
			h.SendError(fmt.Errorf("renderDeferred: %w", err))
		}

		// This needs to be done after the deferred rendering to get complete template usage coverage.

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Unwrap %w and read the template name + line in the error context.
  2. Fix the template (nil checks, correct method names, safeHTML where needed).
  3. Ensure public/ is writable and the disk isn't full.
  4. Re-process or replace corrupt images referenced by failing pages.

Example fix

<!-- before -->
<title>{{ .Title | upper }}</title>
<!-- .Title nil on list page -> render error -->

<!-- after -->
<title>{{ with .Title }}{{ . | upper }}{{ end }}</title>
Defensive patterns

Strategy: try-catch

Validate before calling

// Dry-run templates against sample pages with hugo --renderToMemory to catch render errors pre-build.

Try / catch

if err := h.render(l, conf); err != nil {
    // render errors carry template+line context; surface rather than swallow
    h.SendError(fmt.Errorf("render: %w", err))
}

Prevention

When it happens

Trigger: Raised at hugo_sites_build.go:198 when h.render(infol, conf) returns an error — template execution failures, output filesystem write errors, image/resource transform errors.

Common situations: A template referencing a missing method or nil value; output dir (public/) not writable or full; image processing (resize) failure on a corrupt image; a partial that errors only for specific pages.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/396c0114c0f9615e. Report an issue: GitHub.