siyuan-note/siyuan · error
template definition [ ] not found
Error message
template definition [%s] not found
What it means
validateTemplateCallGraph reports that a {{template "name"}} reference cannot be resolved: root.Lookup(name) returned nil, or the found template has no parse tree/root. SiYuan validates the whole call graph before executing so a missing definition fails fast with a clear message instead of a partial render.
Solutions
- Check the definition name in the error and correct the spelling at the call site
- Add the missing {{define "name"}} ... {{end}} block to the same template set
- If the definition lives in another file of the template package, ensure it is parsed into the same template.Template instance
- Use the "child template definition [%s] not found" check pattern: look up definitions before executing
Example fix
// before
{{template "heder" .}}
// after
{{template "header" .}} Defensive patterns
Strategy: validation
Validate before calling
for _, name := range calledNames { if root.Lookup(name) == nil { return fmt.Errorf("missing definition %s", name) } } Try / catch
if err := validateTemplateCallGraph(root, start); err != nil { return err } Prevention
- Grep template packages for {{template "..."}} and confirm each name has a matching {{define}}
- Rename {{define}} blocks and their call sites together
- Keep all related definitions in files parsed into the same template set
When it happens
Trigger: Raised when walking the template call graph during renderTemplateDocTreeNodeContent: a {{template "x"}} action names a definition that was never defined in the root template or in the parsed child template file.
Common situations: Typo in the template name, referencing a definition defined in another file of a template package that was not loaded, or renaming a {{define}} block without updating its call sites.
Related errors
- createDocTree document contains unknown field
- createDocTree document
- createDocTree document
- createDocTree document template and define are mutually…
- createDocTree document title exceeds
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/c21fcbb42a002733.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template_doc_tree_render.go:119
return nil, fmt.Errorf(Conf.Language(44), err.Error())
}
return buf.Bytes(), nil
}
func validateTemplateCallGraph(root *template.Template, start string) error {
visiting := map[string]bool{}
depths := map[string]int{}
var visit func(string) (int, error)
visit = func(name string) (int, error) {
if visiting[name] {
return 0, fmt.Errorf("recursive template call [%s] is not supported", name)
}
if depth, ok := depths[name]; ok {
return depth, nil
}
tmpl := root.Lookup(name)
if nil == tmpl || nil == tmpl.Tree || nil == tmpl.Tree.Root {
return 0, fmt.Errorf("template definition [%s] not found", name)
}
visiting[name] = true
depth := 1
for _, called := range collectCalledTemplateNames(tmpl.Tree.Root) {
calledDepth, err := visit(called)
if nil != err {
return 0, err
}
if depth < calledDepth+1 {
depth = calledDepth + 1
}
}
delete(visiting, name)
depths[name] = depth
return depth, nil
}
depth, err := visit(start)
if nil != err {View on GitHub (pinned to 9f775e8a12)