{"record":{"id":"7a75125cfed54f15","repo":"gohugoio/hugo","slug":"inner-cannot-be-used-inside-a-with-block-that-wrap","errorCode":null,"errorMessage":"inner cannot be used inside a with block that wraps a partial decorator","messagePattern":"inner cannot be used inside a with block that wraps a partial decorator","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/tplimpl/templatetransform.go","lineNumber":327,"sourceCode":"\t\tcase *parse.WithNode:\n\t\t\tif c.hasBreakOrContinueOutsideRange(x.List) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif c.hasBreakOrContinueOutsideRange(x.ElseList) {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase *parse.BreakNode, *parse.ContinueNode:\n\t\t\treturn true\n\n\t\t}\n\t}\n\treturn false\n}\n\nfunc (c *templateTransformContext) handleWithPartial(withNode *parse.WithNode) {\n\twithNodeInnerString := withNode.List.String()\n\tif templatesInnerRe.MatchString(withNodeInnerString) {\n\t\tc.err = fmt.Errorf(\"inner cannot be used inside a with block that wraps a partial decorator\")\n\t\treturn\n\t}\n\n\t// See #14333. That is a very odd construct, but we need to guard against it.\n\tif c.hasBreakOrContinueOutsideRange(withNode.List) {\n\t\treturn\n\t}\n\tinnerHash := hashing.XxHashFromStringHexEncoded(c.t.Name() + withNodeInnerString)\n\tinternalPartialName := fmt.Sprintf(\"_partials/%s%s\", PartialDecoratorPrefix, innerHash)\n\n\tif c.lookupFn(internalPartialName, c.t) == nil {\n\t\tinnerCopy := withNode.List.CopyList()\n\t\tti, err := c.store.addTransformedTemplateInsert(internalPartialName, SubCategoryInline)\n\t\tif err != nil {\n\t\t\tc.err = fmt.Errorf(\"failed to create internal partial decorator template %q: %w\", internalPartialName, err)\n\t\t\treturn\n\t\t}\n\t\tif ti == nil {","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/tplimpl/templatetransform.go#L309-L345","documentation":"Hugo rewrites certain {{ with partial ... }} blocks into internal partial decorators (handleWithPartial, templatetransform.go:324-329). The regex templatesInnerRe detects a call to templates.Inner or inner inside the with-block's body; because the decorator machinery cannot correctly propagate the inner content in that position, Hugo rejects it explicitly rather than producing broken output.","triggerScenarios":"Writing a template that uses {{ with partial \"foo\" . }}...{{ inner }}...{{ end }} or {{ templates.Inner }} inside the with-body that wraps a partial call. Detected by the regex `{{\\s*(templates\\.Inner\\b|inner\\b)` against the serialized with-node list.","commonSituations":"Trying to use the 'inner' mechanism (intended for shortcodes/decorators) inside a with-partial block; copying shortcode patterns into a partial layout; experimenting with advanced partial decorator features without understanding the constraint.","solutions":["Remove the {{ inner }} / {{ templates.Inner }} call from inside the {{ with partial ... }} block.","Restructure so inner content is passed as a partial parameter or rendered outside the with-block.","If you need partial-overridable blocks, use Hugo's block/define mechanism instead of with+inner."],"exampleFix":"// before\n{{ with partial \"card\" . }}\n  {{ inner }}\n{{ end }}\n\n// after — pass content as a param, do not use inner in with-partial\n{{ partial \"card\" (dict \"ctx\" . \"content\" .Inner) }}","handlingStrategy":"validation","validationCode":"// In template authoring, never use {{ inner }} or {{ templates.Inner }} inside\n// a {{ with partial ... }} ... {{ end }} block. Pass content as a dict arg instead:\n{{ partial \"card\" (dict \"content\" .Inner) }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reserve {{ inner }} for shortcode/decorator contexts, not with-partial blocks.","Pass inner content as a partial parameter via dict.","Use Hugo's block/define for overridable regions instead of with+inner."],"tags":["template","partial","decorator","inner","transform","build"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}