caddyserver/caddy · error

parsing browse template file: %v

Error message

parsing browse template file: %v

What it means

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.

Source

Thrown at modules/caddyhttp/fileserver/browse.go:323

			HttpOnly: true,
			SameSite: http.SameSiteLaxMode,
		})
	}

	// finally, apply the sorting and limiting
	listing.applySortAndLimit(sortParam, orderParam, limitParam, offsetParam)
}

// makeBrowseTemplate creates the template to be used for directory listings.
func (fsrv *FileServer) makeBrowseTemplate(tplCtx *templateContext) (*template.Template, error) {
	var tpl *template.Template
	var err error

	if fsrv.Browse.TemplateFile != "" {
		tpl = tplCtx.NewTemplate(path.Base(fsrv.Browse.TemplateFile))
		tpl, err = tpl.ParseFiles(fsrv.Browse.TemplateFile)
		if err != nil {
			return nil, fmt.Errorf("parsing browse template file: %v", err)
		}
	} else {
		tpl = tplCtx.NewTemplate("default_listing")
		tpl, err = tpl.Parse(BrowseTemplate)
		if err != nil {
			return nil, fmt.Errorf("parsing default browse template: %v", err)
		}
	}

	return tpl, nil
}

// isSymlink return true if f is a symbolic link.
func isSymlink(f fs.FileInfo) bool {
	return f.Mode()&os.ModeSymlink != 0
}

// templateContext powers the context used when evaluating the browse template.

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Verify the file exists at the configured path and is readable by the Caddy process
  2. Mount/copy the template into the container or correct the path
  3. Validate the file parses as a Go text/template (no stray {{)

Example fix

# before
template_file /etc/caddy/missing.html
# after
template_file /etc/caddy/browse.html  # file exists
Defensive patterns

Strategy: validation

Validate before calling

# preflight in deploy script
[ -r "$TPL" ] || { echo "missing template: $TPL"; exit 1; }

Prevention

When it happens

Trigger: 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.

Common situations: Containerized Caddy where the template file wasn't mounted; path typos; file permissions.

Related errors


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/0a6c680c9567ccd1. Report an issue: GitHub.