{"record":{"id":"0d9267e59aed9de8","repo":"gohugoio/hugo","slug":"no-template-found-for-shortcode-q","errorCode":null,"errorMessage":"no template found for shortcode %q","messagePattern":"no template found for shortcode %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/tplimpl/templatestore.go","lineNumber":695,"sourceCode":"\t\t\tisBetter := best.isBetter(weight, vv)\n\t\t\tif isBetter {\n\t\t\t\tbest.updateValues(weight, k2, k, vv)\n\t\t\t}\n\t\t}\n\n\t\treturn false, nil\n\t})\n\n\tif best.w.w1 <= 0 {\n\t\tvar err error\n\t\tif s := best.candidatesAsStringSlice(); s != nil {\n\t\t\tmsg := fmt.Sprintf(\"no compatible template found for shortcode %q in %s\", q.Name, s)\n\t\t\tif !q.Desc.IsPlainText {\n\t\t\t\tmsg += \"; note that to use plain text template shortcodes in HTML you need to use the shortcode {{% delimiter\"\n\t\t\t}\n\t\t\terr = errors.New(msg)\n\t\t} else {\n\t\t\terr = fmt.Errorf(\"no template found for shortcode %q\", q.Name)\n\t\t}\n\t\treturn nil, err\n\t}\n\n\treturn best.templ, nil\n}\n\n// PrintDebug is for testing/debugging only.\nfunc (s *TemplateStore) PrintDebug(prefix string, category Category, w io.Writer) {\n\tif w == nil {\n\t\tw = os.Stdout\n\t}\n\n\tprintOne := func(key string, vv *TemplInfo) {\n\t\tlevel := strings.Count(key, \"/\")\n\t\tif category != vv.category {\n\t\t\treturn\n\t\t}","sourceCodeStart":677,"sourceCodeEnd":713,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/tplimpl/templatestore.go#L677-L713","documentation":"During shortcode lookup, Hugo walks the shortcode template tree (treeShortcodes) for the page path and shortcode name. When no candidate template is found at all (best.w.w1 <= 0 and candidatesAsStringSlice() returns nil), it reports 'no template found for shortcode %q'. This differs from the 'no compatible template' variant which fires when candidates exist but none match the descriptor (templatestore.go:688-696).","triggerScenarios":"Content uses a shortcode {{< foo >}} but no corresponding template file exists under layouts/shortcodes/foo.html (or any path-qualified variant). Called via LookupShortcode(TemplateQuery{Name: \"foo\", ...}) during page rendering.","commonSituations":"Typo in the shortcode name in markdown; shortcode template file placed in the wrong directory (e.g. layouts/partials instead of layouts/shortcodes); removed a theme that provided the shortcode without providing a local replacement; case mismatch (shortcode names are lowercased at templatestore.go:640).","solutions":["Verify the exact shortcode name spelling in both the markdown content and the template filename.","Ensure the template file lives at layouts/shortcodes/<name>.html (or the theme equivalent).","Check that the shortcode isn't only defined in a theme that was removed or not added via theme setup.","Note shortcode names are lowercased — avoid relying on case to distinguish templates."],"exampleFix":"// before — content references undefined shortcode\n{{< mygraph src=\"x\" >}}\n\n// after — create layouts/shortcodes/mygraph.html\n<figure><img src=\"{{ .Get \"src\" }}\"></figure>","handlingStrategy":"validation","validationCode":"// Before building, verify every shortcode referenced in content has a template\n// Quick bash check (run from project root):\n//   grep -rhoE '{{</?[^ >]+|{{%[^%]+%' content/ | sort -u\n// and ensure each name matches layouts/shortcodes/<name>.html","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep shortcode names lowercase and consistently spelled in content and templates.","Place shortcode templates under layouts/shortcodes/ (or the theme's equivalent).","When removing/changing a theme, audit content for shortcodes it provided."],"tags":["shortcode","template-not-found","build","content"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}