kataras/iris · error
no templates found
Error message
no templates found
What it means
HTMLEngine.Load finishes walking the configured filesystem and, if s.Templates is still nil, no template files were found/parsed at all. The library raises this so an empty or misconfigured template root fails loudly at load time rather than returning 'template not found' on every request.
Source
Thrown at view/html.go:299
buf, err := asset(s.fs, path)
if err != nil {
return fmt.Errorf("%s: %w", path, err)
}
return s.parseTemplate(path, buf, nil)
})
if s.onLoaded != nil {
s.onLoaded()
}
if err != nil {
return err
}
if s.Templates == nil {
return fmt.Errorf("no templates found")
}
return nil
}
func (s *HTMLEngine) reloadCustomTemplates() error {
for _, tmpl := range s.customCache {
if err := s.parseTemplate(tmpl.name, tmpl.contents, tmpl.funcs); err != nil {
return err
}
}
return nil
}
// ParseTemplate adds a custom template to the root template.
func (s *HTMLEngine) ParseTemplate(name string, contents []byte, funcs template.FuncMap) (err error) {
s.rmu.Lock()View on GitHub (pinned to 7bedaf55a0)
Solutions
- Fix the go:embed directive or the engine's root directory so it actually contains template files with the registered extension.
- Verify files use the extension passed to html.New (e.g. ".html"); rename or reconfigure.
- Call Load() at startup and check the error so a broken deployment is caught immediately.
Example fix
// before //go:embed views var fs embed.FS engine := html.New(fs, ".html") // views contains .gohtml files only // after engine := html.New(fs, ".gohtml")
Defensive patterns
Strategy: validation
Validate before calling
matched, _ := fs.Glob(tmplFS, "templates/*.html")
if len(matched) == 0 {
log.Fatal("no *.html templates found under templates/ — check embed directive and extension")
} Try / catch
if err := engine.Load(); err != nil {
if strings.Contains(err.Error(), "no templates found") {
log.Fatalf("template root misconfigured: %v", err)
}
return err
} Prevention
- Verify the go:embed pattern actually matches files (empty dirs are not embedded by default).
- Match the engine's extension argument to the real file extensions on disk.
- Assert template count > 0 in an integration test that runs the loader.
- Use embed.All or an explicit directory embed instead of a possibly-empty glob.
When it happens
Trigger: Calling Load (directly or via View.Load / first ExecuteWriter) when the engine's loader found zero files — empty fs root, wrong directory, wrong file extension, or no templates embedded.
Common situations: go:embed pattern matches nothing (e.g. embed of an empty dir); extension mismatch (engine registered with ".html" but files are ".tmpl"); running the binary from a directory where the templates folder doesn't exist in os filesystem mode.
Related errors
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/755f3fbb7f86e02a.
Report an issue: GitHub.