siyuan-note/siyuan · error
Conf.Language(44), err.Error()
Error message
Conf.Language(44), err.Error()
What it means
RenderGoTemplateAtInBox parses the document/template file content as a Go text/template and wraps any parse error with the localized message Conf.Language(44) = "Parse template failed: %s" plus the underlying parser error. It is thrown by the SiYuan kernel when the template text is syntactically invalid Go template syntax.
Solutions
- Read the %s detail in the error — Go reports the exact line and offset of the syntax problem; fix the braces/action in the template file
- Verify every function used inside {{ }} is a registered template func (e.g. now, query blocks, sql funcs); remove or replace unknown ones
- Validate the template with a minimal Go text/template parse outside SiYuan to iterate quickly
- If the error appeared after a SiYuan upgrade, check release notes for removed/renamed template functions
Example fix
// before (template file)
{{ .title } and {{ now.Format "2006" }
// after
{{ .title }} and {{ now.Format "2006" }} Defensive patterns
Strategy: try-catch
Validate before calling
// quick client-side sanity check before calling the API
if (!/\{\{[^}]*\}\}/.test(templateContent) && templateContent.includes("{")) {
console.warn("template contains braces but no valid {{ }} action");
} Try / catch
try {
const html = await fetchPost("/api/template/renderGoTemplate", {id, path});
} catch (e) {
if (String(e.msg).startsWith("Parse template failed")) {
// e.msg ends with Go's line/column detail; surface it to the user for fixing the .md template
}
} Prevention
- Never hand-edit {{ }} actions without matching braces
- Only use functions documented in SiYuan template funcs (BuiltInTemplateFuncs / SQL template funcs)
- Keep templates in <data>/templates/ and test with a small doc before wider use
- Re-test templates after SiYuan upgrades for removed template functions
When it happens
Trigger: Calling RenderGoTemplate / RenderGoTemplateAt / RenderGoTemplateInBox (or the AV new-item template resolution path) with template content containing malformed actions: unbalanced {{ }}, unknown functions, bad pipe/variable syntax in a .md template under <data>/templates/.
Common situations: Hand-edited template files with typos like {{ .title (missing closing braces); using a function not registered in BuiltInTemplateFuncs or sql.SQLTemplateFuncs; copying Go template snippets from another engine (Jinja/Mustache syntax); version changes where a template func was removed or renamed.
Related errors
- Conf.Language(44)
- database [ ] template field [ ] rendering failed
- Parse template failed
- a document tree plan must be applied in a single transaction
- attribute view [ ] has no available view
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/cb486e9920646266.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template.go:93
// RenderGoTemplateAt 使用固定时间渲染 Go 模板,保证同一次业务操作中的多个模板结果一致。
func RenderGoTemplateAt(templateContent string, now time.Time) (ret string, err error) {
return RenderGoTemplateAtInBox(templateContent, now, "")
}
func RenderGoTemplateInBox(templateContent, boxID string) (ret string, err error) {
return RenderGoTemplateAtInBox(templateContent, time.Now(), boxID)
}
func RenderGoTemplateAtInBox(templateContent string, now time.Time, boxID string) (ret string, err error) {
tmpl := template.New("")
tplFuncMap := filesys.BuiltInTemplateFuncs()
tplFuncMap["now"] = func() time.Time { return now }
sql.SQLTemplateFuncs(&tplFuncMap, boxID)
tmpl = tmpl.Funcs(tplFuncMap)
tpl, err := tmpl.Parse(templateContent)
if err != nil {
return "", fmt.Errorf(Conf.Language(44), err.Error())
}
buf := &bytes.Buffer{}
buf.Grow(4096)
err = tpl.Execute(buf, nil)
if err != nil {
return "", fmt.Errorf(Conf.Language(44), err.Error())
}
ret = buf.String()
return
}
// RemoveTemplate 删除模板文件,路径必须限定在 <data>/templates/ 目录内,防止任意文件被删除
func RemoveTemplate(p string) (err error) {
root, rel, err := openTemplatePath(p)
if err != nil {
return err
}View on GitHub (pinned to 9f775e8a12)