siyuan-note/siyuan · error
child template [ ] not found in the current template package
Error message
child template [%s] not found in the current template package
What it means
resolveTemplatePackageFile resolves the package root (the first path segment of the root template under data/templates) and joins the cleaned relative path to it. If the resulting file is not a strict sub-path of the package root or does not exist on disk, the child template reference cannot be satisfied and this error names the missing relative path.
Solutions
- Create or restore the referenced child template file inside the package directory
- Fix the relative path/filename (check case and extension) to match the actual file
- Keep all child templates within the same package root (first-level directory under data/templates)
Example fix
// before: file data/templates/my-package/sub/tpl.md missing
{{child "sub/tpl.md"}} // error
// after: add the file or correct the name
{{child "sub/page.md"}} // data/templates/my-package/sub/page.md exists Defensive patterns
Strategy: validation
Validate before calling
abs := filepath.Join(packageRoot, clean)
if !gulu.File.IsSubPath(packageRoot, abs) || !filelock.IsExist(abs) { /* child missing */ } Try / catch
p, err := resolveTemplatePackageFile(root, rel)
if err != nil && strings.Contains(err.Error(), "not found in the current template package") {
// create the file or correct the reference path
} Prevention
- Ship complete template packages including all child files
- Check filename case and extensions when sharing across OSes
- Verify child references resolve after moving or renaming package files
When it happens
Trigger: A doc-tree template action references a child template file that does not exist inside the same package directory — wrong filename, wrong extension, file deleted, or a path reaching outside the package root (rejected by IsSubPath).
Common situations: Sharing a template package with missing files (e.g. forgot to copy sub/ folder); case-sensitivity mismatches on Linux (Tpl.md vs tpl.md); referencing .md vs .tpl extension wrongly; moving a child out of the package directory.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- attribute view [ ] not found in box [ ]
- attribute view [ ] template plan not found
- child template definition
- Conf.Language(44), err.Error()
- database blocks are not supported by createDocTree templates
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/7860ac8213294cbc.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template_doc_tree.go:416
relativePath = strings.TrimPrefix(filepath.ToSlash(strings.TrimSpace(relativePath)), "/")
cleanPath := filepath.Clean(filepath.FromSlash(relativePath))
if "" == cleanPath || "." == cleanPath || filepath.IsAbs(cleanPath) || ".." == cleanPath ||
strings.HasPrefix(cleanPath, ".."+string(os.PathSeparator)) {
return "", errors.New("invalid child template path")
}
templatesRoot := filepath.Clean(filepath.Join(util.DataDir, "templates"))
relRootTemplate, err := filepath.Rel(templatesRoot, filepath.Clean(rootTemplatePath))
if nil != err || strings.HasPrefix(relRootTemplate, ".."+string(os.PathSeparator)) {
return "", errors.New("template path is outside templates directory")
}
parts := strings.Split(filepath.ToSlash(relRootTemplate), "/")
packageRoot := templatesRoot
if 1 < len(parts) {
packageRoot = filepath.Join(templatesRoot, parts[0])
}
absPath := filepath.Join(packageRoot, cleanPath)
if !gulu.File.IsSubPath(packageRoot, absPath) || !filelock.IsExist(absPath) {
return "", fmt.Errorf("child template [%s] not found in the current template package", relativePath)
}
realRoot, err := filepath.EvalSymlinks(packageRoot)
if nil != err {
return "", err
}
realPath, err := filepath.EvalSymlinks(absPath)
if nil != err {
return "", err
}
info, err := os.Stat(realPath)
if nil != err || !info.Mode().IsRegular() {
return "", fmt.Errorf("child template [%s] is not a regular file", relativePath)
}
if !gulu.File.IsSubPath(realRoot, realPath) {
return "", errors.New("child template path is outside the current template package")
}
return realPath, nil
}View on GitHub (pinned to 9f775e8a12)