{"record":{"id":"12432e1eabab658e","repo":"gohugoio/hugo","slug":"failed-to-parse-empty-html-template-q-w","errorCode":null,"errorMessage":"failed to parse empty HTML template %q: %w","messagePattern":"failed to parse empty HTML template %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/tplimpl/templatestore.go","lineNumber":935,"sourceCode":"\tif _, found := t.templatesByPath.Get(name); found {\n\t\treturn nil\n\t}\n\n\tvar templ tpl.Template\n\n\tif owner.D.IsPlainText {\n\t\tprototype := t.tns.parseText\n\t\ttt, err := prototype.New(name).Parse(\"\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse empty text template %q: %w\", name, err)\n\t\t}\n\t\ttt.Tree.Root = n\n\t\ttempl = tt\n\t} else {\n\t\tprototype := t.tns.parseHTML\n\t\ttt, err := prototype.New(name).Parse(\"\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse empty HTML template %q: %w\", name, err)\n\t\t}\n\t\ttt.Tree.Root = n\n\t\ttempl = tt\n\t}\n\n\tt.templatesByPath.Set(name, &TemplInfo{\n\t\tFi:       owner.Fi,\n\t\tPathInfo: owner.PathInfo,\n\t\tD:        owner.D,\n\t\tTemplate: templ,\n\t})\n\n\treturn nil\n}\n\nfunc (s *TemplateStore) addFileContext(ti *TemplInfo, what string, inerr error) error {\n\tif ti.Fi == nil {\n\t\treturn inerr","sourceCodeStart":917,"sourceCodeEnd":953,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/tplimpl/templatestore.go#L917-L953","documentation":"The HTML counterpart of the empty text template parse: in addDeferredTemplate (templatestore.go:931-935) the HTML template prototype's New(name).Parse(\"\") is used to seed a deferred HTML template. Failure here wraps the underlying html/template parse error. Parsing an empty string should not fail, so this indicates an anomalous/internal condition.","triggerScenarios":"Internal registration of a deferred HTML template where the htmltemplate prototype is corrupted or its func map is in an invalid state. Surfaces during build when deferred rendering constructs are processed.","commonSituations":"Not expected in normal builds. Could appear in Hugo development/forking scenarios where the html template prototype's funcs are modified, or due to a regression in a Hugo release affecting the deferred template path.","solutions":["Treat as a Hugo internal error; report with the template name and Hugo version.","Upgrade Hugo to the latest stable release.","Bisect recently added templates/layouts to find a trigger if reproducible.","Avoid any code that mutates the internal parseHTML prototype."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Internal error; in Go integration tests, surface distinctly:\nif strings.Contains(err.Error(), \"failed to parse empty HTML template\") {\n    t.Fatalf(\"Hugo internal HTML template parse failure: %v\", err)\n}","preventionTips":["Avoid forking Hugo's html template prototype.","Update Hugo regularly.","Bisect new layouts if the error appears after a change."],"tags":["template","deferred","internal","parse-error","html"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}