{"record":{"id":"0a6c680c9567ccd1","repo":"caddyserver/caddy","slug":"parsing-browse-template-file-v","errorCode":null,"errorMessage":"parsing browse template file: %v","messagePattern":"parsing browse template file: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"modules/caddyhttp/fileserver/browse.go","lineNumber":323,"sourceCode":"\t\t\tHttpOnly: true,\n\t\t\tSameSite: http.SameSiteLaxMode,\n\t\t})\n\t}\n\n\t// finally, apply the sorting and limiting\n\tlisting.applySortAndLimit(sortParam, orderParam, limitParam, offsetParam)\n}\n\n// makeBrowseTemplate creates the template to be used for directory listings.\nfunc (fsrv *FileServer) makeBrowseTemplate(tplCtx *templateContext) (*template.Template, error) {\n\tvar tpl *template.Template\n\tvar err error\n\n\tif fsrv.Browse.TemplateFile != \"\" {\n\t\ttpl = tplCtx.NewTemplate(path.Base(fsrv.Browse.TemplateFile))\n\t\ttpl, err = tpl.ParseFiles(fsrv.Browse.TemplateFile)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"parsing browse template file: %v\", err)\n\t\t}\n\t} else {\n\t\ttpl = tplCtx.NewTemplate(\"default_listing\")\n\t\ttpl, err = tpl.Parse(BrowseTemplate)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"parsing default browse template: %v\", err)\n\t\t}\n\t}\n\n\treturn tpl, nil\n}\n\n// isSymlink return true if f is a symbolic link.\nfunc isSymlink(f fs.FileInfo) bool {\n\treturn f.Mode()&os.ModeSymlink != 0\n}\n\n// templateContext powers the context used when evaluating the browse template.","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/fileserver/browse.go#L305-L341","documentation":"makeBrowseTemplate failed to ParseFiles the user-configured Browse.TemplateFile. The wrapped error is typically 'open ...: no such file' or a template parse failure for the custom file on disk.","triggerScenarios":"browse { template_file /path/to/tpl.html } where the path is wrong, unreadable, or contains invalid template syntax; the file is read at request time from that path.","commonSituations":"Containerized Caddy where the template file wasn't mounted; path typos; file permissions.","solutions":["Verify the file exists at the configured path and is readable by the Caddy process","Mount/copy the template into the container or correct the path","Validate the file parses as a Go text/template (no stray {{) "],"exampleFix":"# before\ntemplate_file /etc/caddy/missing.html\n# after\ntemplate_file /etc/caddy/browse.html  # file exists","handlingStrategy":"validation","validationCode":"# preflight in deploy script\n[ -r \"$TPL\" ] || { echo \"missing template: $TPL\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mount template files into containers and health-check readability","Use absolute paths for template_file"],"tags":["caddy","fileserver","browse","template","filesystem"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}