{"record":{"id":"d6290d21a20ece9d","repo":"siyuan-note/siyuan","slug":"child-template-definition-s-not-found","errorCode":null,"errorMessage":"child template definition [%s] not found","messagePattern":"child template definition \\[(.+?)\\] not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_doc_tree_render.go","lineNumber":73,"sourceCode":"\nfunc renderTemplateDocTreeNodeContent(collector *templateDocTreeCollector, rootTemplate *template.Template,\n\tfuncs template.FuncMap, node *TemplateDocTreeNode) ([]byte, error) {\n\tif \"\" == node.Template && \"\" == node.Define {\n\t\treturn nil, nil\n\t}\n\n\tpreviousAllowCreation := collector.allowCreation\n\tcollector.allowCreation = false\n\tdefer func() {\n\t\tcollector.allowCreation = previousAllowCreation\n\t}()\n\n\tbuf := &bytes.Buffer{}\n\tbuf.Grow(4096)\n\tdataModel := templateDocTreeDataModel(node)\n\tif \"\" != node.Define {\n\t\tif nil == rootTemplate.Lookup(node.Define) {\n\t\t\treturn nil, fmt.Errorf(\"child template definition [%s] not found\", node.Define)\n\t\t}\n\t\tif err := validateTemplateCallGraph(rootTemplate, node.Define); nil != err {\n\t\t\treturn nil, err\n\t\t}\n\t\tif err := rootTemplate.ExecuteTemplate(buf, node.Define, dataModel); nil != err {\n\t\t\treturn nil, fmt.Errorf(Conf.Language(44), err.Error())\n\t\t}\n\t\treturn buf.Bytes(), nil\n\t}\n\n\tchildPath, err := resolveTemplatePackageFile(collector.templatePath, node.Template)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\tcontent, err := os.ReadFile(childPath)\n\tif nil != err {\n\t\treturn nil, err\n\t}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template_doc_tree_render.go#L55-L91","documentation":"When a doc-tree node specifies node.Define, the kernel expects that name to be a template definition ({{define \"name\"}} or .action{template ...} define) already parsed into the root template set. rootTemplate.Lookup returns nil when no such definition exists, so rendering of that node fails with this error before execution.","triggerScenarios":"A TemplateDocTreeNode has Define set to a name that was never declared via {{define \"...\"}} in the root template, or the define name is misspelled / differs in case, or the template file containing the define failed to parse into the root set.","commonSituations":"Typo in the define name in the doc-tree config vs the {{define}} block; renaming a define without updating node.Define; the parent template file with the define was not included in the parsed root template.","solutions":["Make node.Define exactly match an existing {{define \"name\"}} in the root template (check spelling and case)","Add the missing {{define \"...\"}} block to the root template file","Ensure the file containing the define is actually loaded into the root template set before rendering","If the node should load an external file instead, clear Define and set node.Template to the file path"],"exampleFix":"// before: node.Define = \"childSection\" but template has\n{{define \"child-section\"}}...{{end}}\n// after: align names\n{{define \"childSection\"}}...{{end}}  // or set node.Define = \"child-section\"","handlingStrategy":"validation","validationCode":"if node.Define != \"\" && rootTemplate.Lookup(node.Define) == nil {\n\treturn fmt.Errorf(\"define %q is not present in the root template set\", node.Define)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep define names in a shared constant/list referenced by both {{define}} and node.Define","Grep template files for {{define \"...\"}} names and validate node.Define against them at load time","Prefer node.Template file paths over Define unless the define is verified to exist"],"tags":["go","template","not-found","rendering"],"backgroundTag":"resource-not-found","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}