# Panic after command

**URL:** <https://discourse.gohugo.io/t/panic-after-command/57604>\
**Category:** support\
**Created:** [September 29, 2026, 12:56pm UTC](https://discourse.gohugo.io/t/panic-after-command/57604 "2026-09-29T12:56:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mriambez](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@mriambez](https://discourse.gohugo.io/u/mriambez)\
**Post date:** [September 29, 2026, 12:56pm UTC](https://discourse.gohugo.io/t/panic-after-command/57604/1 "2026-09-29T12:56:41Z")

</div>

Should this be happening? Or am I using the `--panicOnWarning` wrongly?

```auto
$ hugo --printUnusedTemplates --panicOnWarning
Start building sites … 
hugo v0.167.0-3fff6fb5c267dacb26280c78dbe8c344054249c8+extended linux/amd64 BuildDate=2026-09-28T14:50:38Z VendorInfo=gohugoio

WARN Template /_partials/author_pages.html is unused, source ".../layouts/_partials/author_pages.html"
panic: Template /_partials/author_pages.html is unused, source "/.../layouts/_partials/author_pages.html"

goroutine 20 [running]:
github.com/gohugoio/hugo/common/loggers.init.func1(0x2657a2ca0750?)
	/root/project/hugo/common/loggers/handlersmisc.go:32 +0x3e
github.com/gohugoio/hugo/common/loggers.New.func2(0x2657b16b17c8?)
	/root/project/hugo/common/loggers/logger.go:93 +0x17
github.com/bep/logg.HandlerFunc.HandleLog(0x2657a00b6120?, 0x2657a7a6eae0?)
	/root/project/gomodcache/github.com/bep/logg@v0.4.0/handler.go:26 +0x19
github.com/bep/logg/handlers/multi.(*Handler).HandleLog(0x2657a0482af8?, 0x2657a7a6eae0)
	/root/project/gomodcache/github.com/bep/logg@v0.4.0/handlers/multi/multi.go:26 +0x4e
github.com/gohugoio/hugo/common/loggers.(*stopHandler).HandleLog(0x2657a0498fc0?, 0x2657a7a6eae0)
	/root/project/hugo/common/loggers/handlersmisc.go:109 +0x54
github.com/bep/logg.(*logger).log(0x2657a00b61e0, 0x2657a0498fc0, {0x3137f58, 0x2657ac46e8a0})
	/root/project/gomodcache/github.com/bep/logg@v0.4.0/logger.go:154 +0x105
github.com/bep/logg.(*Entry).Logf(0x2657a0498fc0, {0x19e62cf, 0x20}, {0x2657a5b60a20, 0x2, 0x2})
	/root/project/gomodcache/github.com/bep/logg@v0.4.0/entry.go:113 +0xb8
github.com/gohugoio/hugo/common/loggers.(*logAdapter).Warnf(0x2657a005f650?, {0x19e62cf?, 0x2657a0498f00?}, {0x2657a5b60a20?, 0x193d780?, 0x3f841e0?})
	/root/project/hugo/common/loggers/logger.go:313 +0x2c
github.com/gohugoio/hugo/hugolib.(*HugoSites).printUnusedTemplatesOnce.func1()
	/root/project/hugo/hugolib/hugo_sites_build.go:639 +0x1a3
sync.(*Once).doSlow(0xffffffffffffffff?, 0x0?)
	/usr/local/go/src/sync/once.go:78 +0xab
sync.(*Once).Do(...)
	/usr/local/go/src/sync/once.go:69
github.com/gohugoio/hugo/hugolib.(*HugoSites).printUnusedTemplatesOnce(0x2657a089d8c8?)
	/root/project/hugo/hugolib/hugo_sites_build.go:633 +0x3b
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0x2657a089d8c8, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, {0x0, ...})
	/root/project/hugo/hugolib/hugo_sites_build.go:217 +0xd97
github.com/gohugoio/hugo/commands.(*hugoBuilder).buildSites(0x0?, 0x0)
	/root/project/hugo/commands/hugobuilder.go:451 +0x105
github.com/gohugoio/hugo/commands.(*hugoBuilder).fullBuild.func3()
	/root/project/hugo/commands/hugobuilder.go:625 +0x1f
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/root/project/gomodcache/golang.org/x/sync@v0.23.0/errgroup/errgroup.go:93 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
	/root/project/gomodcache/golang.org/x/sync@v0.23.0/errgroup/errgroup.go:78 +0xa5

```

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [September 29, 2026, 1:08pm UTC](https://discourse.gohugo.io/t/panic-after-command/57604/2 "2026-09-29T13:08:11Z")

</div>

Exactly as you requested:

- without the command line parameters `hugo` just ignores unused templates

- `--printUnusedTemplates` instructs to print a warning for each unused template  
which results in line 5 (`WARN Template...`)

- `--panicOnWarning` panics if any warning has been detected  
which results in line 6 (`panic: Template ...`)

- looks like it does not collect all warnings and panics at the end but immediately does. Maybe for other types of warnings you could get more warnings before the panic bacause of concurrency; unsure about that.
