{"record":{"id":"9b65a6ae1a23ae69","repo":"gohugoio/hugo","slug":"rendered-shortcode-q-not-found","errorCode":null,"errorMessage":"rendered shortcode %q not found","messagePattern":"rendered shortcode %q not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"hugolib/page__content.go","lineNumber":244,"sourceCode":"\tc := make([]byte, 0, len(source)+(len(source)/10))\n\tvar sm []sourceMapEntry\n\n\tfor _, it := range pi.itemsStep2 {\n\t\tswitch v := it.(type) {\n\t\tcase pageparser.Item:\n\t\t\tsm = append(sm, sourceMapEntry{renderOffset: len(c), sourceOffset: v.Pos()})\n\t\t\tc = append(c, source[v.Pos():v.Pos()+len(v.Val(source))]...)\n\t\tcase pageContentReplacement:\n\t\t\tsm = append(sm, sourceMapEntry{renderOffset: len(c), sourceOffset: v.source.Pos()})\n\t\t\tc = append(c, v.val...)\n\t\tcase *shortcode:\n\t\t\tsm = append(sm, sourceMapEntry{renderOffset: len(c), sourceOffset: v.pos, isShortcode: true})\n\t\t\tif !v.insertPlaceholder() {\n\t\t\t\t// Insert the rendered shortcode.\n\t\t\t\trenderedShortcode, found := renderedShortcodes[v.placeholder]\n\t\t\t\tif !found {\n\t\t\t\t\t// This should never happen.\n\t\t\t\t\tpanic(fmt.Sprintf(\"rendered shortcode %q not found\", v.placeholder))\n\t\t\t\t}\n\n\t\t\t\tb, more, err := renderedShortcode.renderShortcode(ctx)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, nil, false, fmt.Errorf(\"failed to render shortcode: %w\", err)\n\t\t\t\t}\n\t\t\t\thasVariants = hasVariants || more\n\t\t\t\tc = append(c, []byte(b)...)\n\n\t\t\t} else {\n\t\t\t\t// Insert the placeholder so we can insert the content after\n\t\t\t\t// markdown processing.\n\t\t\t\tc = append(c, []byte(v.placeholder)...)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"unknown item type %T\", it))\n\t\t}\n\t}","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/page__content.go#L226-L262","documentation":"Panic during content assembly: a shortcode placeholder recorded in the source map is not present in the renderedShortcodes map. The inline comment says 'This should never happen', marking it an internal invariant failure in shortcode rendering bookkeeping. The rendered-shortcode map should always contain every placeholder written into the source.","triggerScenarios":"The renderedShortcodes map is populated during shortcode rendering but a placeholder written by the parser is missing from it — caused by a mismatch between shortcode parsing and rendering passes, concurrent map mutation, or an incremental build that retained stale placeholders. Usually an internal bug.","commonSituations":"Complex nested shortcodes, shortcodes that produce variants/deferred content, incremental builds with stale shortcode state. A Hugo version change in the shortcode protocol with leftover cache.","solutions":["Clean-rebuild (clear public/, resources/_gen, build lock) to discard stale shortcode state.","Simplify the failing shortcode (reduce nesting / deferred content) to isolate the bug.","Upgrade Hugo; report the placeholder and shortcode template if it reproduces."],"exampleFix":"# before\nhugo  # incremental build hits stale shortcode placeholder\n\n# after\nrm -rf public resources/_gen .hugo_build.lock && hugo","handlingStrategy":"validation","validationCode":"// Not directly preventable by API users — internal invariant.\n// Mitigate: clean-rebuild (rm -rf public resources/_gen .hugo_build.lock && hugo)\n// and simplify nested/deferred shortcodes.","typeGuard":null,"tryCatchPattern":"// Wrap Build in recover() to surface the placeholder cleanly (see 781).","preventionTips":["Clean the cache when shortcode panics appear.","Reduce shortcode nesting/deferred content.","Keep Hugo updated.","Report the placeholder and shortcode template upstream."],"tags":["shortcodes","content","rendering","panic","internal-invariant"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}