gohugoio/hugo · error

failed to find internal partial decorator template %q after

Error message

failed to find internal partial decorator template %q after insertion

What it means

After calling addTransformedTemplateInsert to register the decorator, Hugo expects a non-nil TemplInfo back (templatetransform.go:345-347). If the insertion reported success but returned nil template info — an invariant violation — this defensive error is raised. It guards against silent corruption of the template store during decorator synthesis.

Source

Thrown at tpl/tplimpl/templatetransform.go:346

		return
	}

	// See #14333. That is a very odd construct, but we need to guard against it.
	if c.hasBreakOrContinueOutsideRange(withNode.List) {
		return
	}
	innerHash := hashing.XxHashFromStringHexEncoded(c.t.Name() + withNodeInnerString)
	internalPartialName := fmt.Sprintf("_partials/%s%s", PartialDecoratorPrefix, innerHash)

	if c.lookupFn(internalPartialName, c.t) == nil {
		innerCopy := withNode.List.CopyList()
		ti, err := c.store.addTransformedTemplateInsert(internalPartialName, SubCategoryInline)
		if err != nil {
			c.err = fmt.Errorf("failed to create internal partial decorator template %q: %w", internalPartialName, err)
			return
		}
		if ti == nil {
			c.err = fmt.Errorf("failed to find internal partial decorator template %q after insertion", internalPartialName)
			return
		}

		cc := newTemplateTransformContext(ti, c.store, c.lookupFn)

		tree, err := c.store.addTransformedTemplateSetTree(ti, innerCopy)
		if err != nil {
			c.err = fmt.Errorf("failed to add internal partial decorator template %q: %w", internalPartialName, err)
			return
		}

		if err := cc.applyTransformationsAndSetReturnWrapper(tree); err != nil {
			c.err = fmt.Errorf("failed to transform internal partial decorator template %q: %w", internalPartialName, err)
			return
		}

	}

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Treat as a Hugo internal bug; report with the internal partial name and a reproducer.
  2. Update Hugo to the latest version.
  3. Bisect templates/layouts to find a minimal trigger if reproducible.
Defensive patterns

Strategy: try-catch

Try / catch

// Defensive: treat this invariant violation as a fatal internal bug:
if err != nil && strings.Contains(err.Error(), "failed to find internal partial decorator template") {
    panic(fmt.Sprintf("Hugo invariant violation: %v", err))
}

Prevention

When it happens

Trigger: An internal inconsistency where addTransformedTemplateInsert returns (nil, nil) — no error but no template. This should not happen under normal control flow and indicates a logic bug in the store's insertion path.

Common situations: Not expected in normal builds. Would surface only from a Hugo internal regression or a heavily customized template pipeline.

Related errors


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