{"id":"bc2731b74790c68f","repo":"gohugoio/hugo","slug":"template-s-not-parsed","errorCode":null,"errorMessage":"template %s not parsed","messagePattern":"template (.+?) not parsed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"tpl/tplimpl/templatetransform.go","lineNumber":84,"sourceCode":"\t\ttemplateNotFound: make(map[string]bool),\n\t\tdeferNodes:       make(map[string]*parse.ListNode),\n\t}\n}\n\nfunc applyTemplateTransformers(\n\tt *TemplInfo,\n\tstore *TemplateStore,\n\tlookupFn func(name string, in *TemplInfo) *TemplInfo,\n) (*templateTransformContext, error) {\n\tif t == nil {\n\t\treturn nil, errors.New(\"expected template, but none provided\")\n\t}\n\n\tc := newTemplateTransformContext(t, store, lookupFn)\n\tc.t.ParseInfo = defaultParseInfo\n\ttree := getParseTree(t.Template)\n\tif tree == nil {\n\t\tpanic(fmt.Errorf(\"template %s not parsed\", t))\n\t}\n\n\tif err := c.applyTransformationsAndSetReturnWrapper(tree); err != nil {\n\t\treturn c, fmt.Errorf(\"failed to transform template %q: %w\", t.Name(), err)\n\t}\n\n\treturn c, c.err\n}\n\nfunc getParseTree(templ tpl.Template) *parse.Tree {\n\tif text, ok := templ.(*texttemplate.Template); ok {\n\t\treturn text.Tree\n\t}\n\treturn templ.(*htmltemplate.Template).Tree\n}\n\nconst (\n\t// We parse this template and modify the nodes in order to assign","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/tplimpl/templatetransform.go#L66-L102","documentation":"Internal panic in Hugo's template transformer (applyTemplateTransformers in tpl/tplimpl/templatetransform.go). Before applying node transformations, Hugo fetches the parse tree of the template via getParseTree; a nil tree means the template object was never parsed by text/template or html/template, which should be impossible in a healthy build, so Hugo panics rather than continuing with a corrupt template store.","triggerScenarios":"A *TemplInfo reaches applyTemplateTransformers with a Template whose Tree field is nil — i.e. a template registered in the TemplateStore without going through parsing. Normally only reachable via a Hugo bug, a corrupt module/theme template load, or custom code embedding hugolib that inserts unparsed templates.","commonSituations":"Users hit this as a panic stack trace during 'hugo' or 'hugo server', typically after a Hugo version upgrade that changed the template store, or with unusual template setups (inline partials, template redefinition across theme components) that expose an edge case in template registration.","solutions":["Run 'hugo --logLevel debug' to identify which template triggers the panic, and check that template file for syntax that fails to parse cleanly.","Upgrade to the latest Hugo release — panics in the template transformer are treated as bugs and fixed quickly.","Bisect by removing recently added/changed templates (especially inline templates defined with {{ define }}) to find the offender.","If reproducible on latest Hugo, file an issue at github.com/gohugoio/hugo with a minimal reproducer, as this indicates an internal bug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure the template exists before referencing it\n{{ if templates.Exists \"partials/mypartial.html\" }}\n  {{ partial \"mypartial.html\" . }}\n{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify template names/paths match the layouts directory exactly before referencing them","Run `hugo --printPathWarnings` locally to catch unresolved templates","Guard optional partials with templates.Exists before invoking them"],"tags":["hugo","templates","panic","internal"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}