{"record":{"id":"10ee2f8a81b9b049","repo":"gohugoio/hugo","slug":"s-template-for-shortcode-q-not-found","errorCode":null,"errorMessage":"%s: template for shortcode %q not found","messagePattern":"(.+?): template for shortcode %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/shortcode.go","lineNumber":671,"sourceCode":"\t\t\tif next.IsRightShortcodeDelim() {\n\t\t\t\t// self-closing\n\t\t\t\tpt.Consume(1)\n\t\t\t} else {\n\t\t\t\tsc.isClosing = true\n\t\t\t\tpt.Consume(2)\n\t\t\t}\n\t\t\treturn sc, nil\n\t\tcase currItem.IsText():\n\t\t\tsc.inner = append(sc.inner, currItem.ValStr(source))\n\t\tcase currItem.IsShortcodeName():\n\n\t\t\tsc.name = currItem.ValStr(source)\n\n\t\t\t// Used to check if the template expects inner content,\n\t\t\t// so just pick one arbitrarily with the same name.\n\t\t\ttempl := s.firstTemplateStore.LookupShortcodeByName(sc.name)\n\t\t\tif templ == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"%s: template for shortcode %q not found\", errorPrefix, sc.name)\n\t\t\t}\n\t\t\tsc.templ = templ\n\t\tcase currItem.IsInlineShortcodeName():\n\t\t\tsc.name = currItem.ValStr(source)\n\t\t\tsc.isInline = true\n\t\tcase currItem.IsShortcodeParam():\n\t\t\tif !pt.IsValueNext() {\n\t\t\t\tcontinue\n\t\t\t} else if pt.Peek().IsShortcodeParamVal() {\n\t\t\t\t// named params\n\t\t\t\tif sc.params == nil {\n\t\t\t\t\tparams := make(map[string]any)\n\t\t\t\t\tparams[currItem.ValStr(source)] = pt.Next().ValTyped(source)\n\t\t\t\t\tsc.params = params\n\t\t\t\t} else {\n\t\t\t\t\tif params, ok := sc.params.(map[string]any); ok {\n\t\t\t\t\t\tparams[currItem.ValStr(source)] = pt.Next().ValTyped(source)\n\t\t\t\t\t} else {","sourceCodeStart":653,"sourceCodeEnd":689,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/shortcode.go#L653-L689","documentation":"Raised in extractShortcode (shortcode.go:671) during the parsing of a shortcode name token: s.firstTemplateStore.LookupShortcodeByName returns nil, meaning no shortcode template with that name is registered in any template store reachable from the page. This fires at parse time, before rendering, while Hugo decides whether the shortcode expects inner content.","triggerScenarios":"Using {{< foo >}} when no layouts/shortcodes/foo.html (or theme equivalent) exists; a typo in the shortcode name; the shortcode lives only in a theme that is not mounted; output-format/language mismatch so the lookup set excludes the only defining template.","commonSituations":"Switching themes and forgetting to migrate custom shortcodes; content referencing a shortcode that was renamed/removed; theme not added to hugo.toml; shortcode names with case differences (shortcode names are case-sensitive in lookup).","solutions":["Create layouts/shortcodes/<name>.html (or .amber/.ace per your template engine) in the project or theme.","Correct the shortcode name in the content to match an existing template exactly (case-sensitive).","Ensure the theme providing the shortcode is listed under `theme`/`module.imports` and mounted."],"exampleFix":"{{/* before: no such shortcode */}}\n{{< greeeting >}}\n\n{{/* after */}}\n{{< greeting >}}\n# and create layouts/shortcodes/greeting.html","handlingStrategy":"validation","validationCode":"# Verify every shortcode name used in content has a template.\nused=$(grep -rhoE '\\{\\{[%<][[:space:]]*[a-zA-Z0-9_-]+' content | sed -E 's/.*[[:space:]]+//' | sort -u)\nfor name in $used; do\n  find layouts -path \"*/shortcodes/${name}.html\" | grep -q . || echo \"missing shortcode template: $name\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a project convention: every shortcode name maps 1:1 to layouts/shortcodes/<name>.html.","When switching themes, copy custom shortcodes or add shim templates.","Run the shortcode/template audit above in CI."],"tags":["shortcode","templates","missing-template"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}