gohugoio/hugo · error
failed to add internal partial decorator template %q: %w
Error message
failed to add internal partial decorator template %q: %w
What it means
After inserting the decorator template info, Hugo sets its parse tree via store.addTransformedTemplateSetTree (templatetransform.go:352-355). If assigning the cloned inner node list to the template's tree fails, the error is wrapped with the internal decorator name. This is an internal step in synthesizing the partial decorator.
Source
Thrown at tpl/tplimpl/templatetransform.go:354
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
}
}
newInner := popPartialDecorator.CopyList()
ifNode := newInner.Nodes[0].(*parse.IfNode)
placeholderPipe := ifNode.Pipe.Cmds[0].Args[0].(*parse.PipeNode)
// Set PLACEHOLDER1 to the unique ID for this partial decorator.
sn1 := placeholderPipe.Cmds[0].Args[1].(*parse.PipeNode).Cmds[0].Args[0].(*parse.StringNode)
sn1.Text = innerHashView on GitHub (pinned to 52c9bd7908)
Solutions
- Inspect the wrapped error for the underlying cause.
- Simplify the with-partial template to isolate the trigger.
- Report as a Hugo bug with a reproducer if it occurs on stock Hugo.
- Update Hugo.
Defensive patterns
Strategy: try-catch
Try / catch
// Surface the wrapped cause during diagnosis:
if err != nil && strings.Contains(err.Error(), "failed to add internal partial decorator template") {
log.Fatalf("decorator tree set failed: %v", err)
} Prevention
- Simplify with-partial blocks to isolate triggers.
- Update Hugo.
- Report persistent occurrences upstream.
When it happens
Trigger: Failure inside addTransformedTemplateSetTree when assigning the deferred/inner node list to the synthesized decorator template. Triggered during the transform of a with-partial block.
Common situations: Rare internal failure; may indicate a template-name collision or a parse-tree assignment problem in a custom Hugo build or an edge-case template.
Related errors
- failed to create internal partial decorator template %q: %w
- failed to transform internal partial decorator template %q:
- inner cannot be used inside a with block that wraps a partia
- failed to find internal partial decorator template %q after
- maximum template call stack size exceeded in %q
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/64b6bf3e68be869e.
Report an issue: GitHub.