{"record":{"id":"6d07c829bcf0f520","repo":"gohugoio/hugo","slug":"template-q-not-found-6d07c8","errorCode":null,"errorMessage":"template %q not found","messagePattern":"template %q not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"hugolib/hugo_sites_build.go","lineNumber":556,"sourceCode":"\n\t\t\tlow, high := k+l, k+l+m\n\n\t\t\tforward := l + m\n\t\t\tid := string(content[low:high])\n\n\t\t\tif err := func() error {\n\t\t\t\tdeferred, found := de.Executions.Get(id)\n\t\t\t\tif !found {\n\t\t\t\t\tpanic(fmt.Sprintf(\"deferred execution with id %q not found\", id))\n\t\t\t\t}\n\t\t\t\tdeferred.Mu.Lock()\n\t\t\t\tdefer deferred.Mu.Unlock()\n\n\t\t\t\tif !deferred.Executed {\n\t\t\t\t\ttmpl := s.Deps.GetTemplateStore()\n\t\t\t\t\tti := s.TemplateStore.LookupByPath(deferred.TemplatePath)\n\t\t\t\t\tif ti == nil {\n\t\t\t\t\t\tpanic(fmt.Sprintf(\"template %q not found\", deferred.TemplatePath))\n\t\t\t\t\t}\n\n\t\t\t\t\tif err := func() error {\n\t\t\t\t\t\tbuf := bufferpool.GetBuffer()\n\t\t\t\t\t\tdefer bufferpool.PutBuffer(buf)\n\n\t\t\t\t\t\terr = tmpl.ExecuteWithContext(deferred.Ctx, ti, buf, deferred.Data)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdeferred.Result = buf.String()\n\t\t\t\t\t\tdeferred.Executed = true\n\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}(); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/hugo_sites_build.go#L538-L574","documentation":"Panic raised while executing a deferred template: the deferred entry references a TemplatePath, but LookupByPath on the template store returns nil. This means a template path recorded during the render pass is no longer resolvable at execution time. Like 781 it is an internal consistency error in Hugo's deferred-template lifecycle.","triggerScenarios":"A deferred template/partial whose path was registered but whose template was removed, renamed, or not loaded into the TemplateStore used at resolution time. Reentering rendering after template changes without rebuilding the store. A baseof/override mismatch where the looked-up path does not exist.","commonSituations":"Editing or renaming a partial that participates in a deferred execution during a live reload/incremental build. Mismatched theme vs project template paths. Hugo version change altering how template paths are keyed. A layout referenced by a render hook that is missing from the working dir.","solutions":["Clean-rebuild to discard stale template references (clear public/ and the Hugo cache).","Verify the template/partial file at the path reported in the panic exists in layouts/ (or the theme) and has no typos.","Restart the hugo server / process to rebuild the template store fresh.","Upgrade Hugo; report the issue with the deferred TemplatePath if it reproduces on a clean build."],"exampleFix":"// layouts/_default/_markup/render-link.html was renamed during live reload\n# Fix: ensure the referenced template path exists, then rebuild\nrm -rf public resources/_gen && hugo server --disableFastRender","handlingStrategy":"validation","validationCode":"// Validate that referenced partials/templates exist before building.\n// In templates, prefer partial names that resolve at parse time.\n// Before a build you can list loaded templates via the deps template store if embedding Hugo.","typeGuard":null,"tryCatchPattern":"// Wrap Build to convert panics into errors (see 781). Not a substitute for fixing the missing template.","preventionTips":["Ensure every partial referenced by name exists under layouts/.","Clean-rebuild after renaming templates.","Restart the hugo server after structural template changes.","Keep theme and project template paths consistent."],"tags":["deferred-template","templates","build","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"}