@@ -176,12 +176,18 @@ func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
176
176
return err
177
177
}
178
178
179
+ // We need to do this before render deferred.
180
+ if err := h .printPathWarningsOnce (); err != nil {
181
+ h .SendError (fmt .Errorf ("printPathWarnings: %w" , err ))
182
+ }
183
+
179
184
if err := h .renderDeferred (infol ); err != nil {
180
185
h .SendError (fmt .Errorf ("renderDeferred: %w" , err ))
181
186
}
182
187
183
- if err := h .postRenderOnce (); err != nil {
184
- h .SendError (fmt .Errorf ("postRenderOnce: %w" , err ))
188
+ // This needs to be done after the deferred rendering to get complete template usage coverage.
189
+ if err := h .printUnusedTemplatesOnce (); err != nil {
190
+ h .SendError (fmt .Errorf ("printPathWarnings: %w" , err ))
185
191
}
186
192
187
193
if err := h .postProcess (infol ); err != nil {
@@ -545,9 +551,9 @@ func (s *Site) executeDeferredTemplates(de *deps.DeferredExecutions) error {
545
551
return g .Wait ()
546
552
}
547
553
548
- // / postRenderOnce runs some post processing that only needs to be done once, e.g. printing of unused templates .
549
- func (h * HugoSites ) postRenderOnce () error {
550
- h .postRenderInit .Do (func () {
554
+ // printPathWarningsOnce prints path warnings if enabled .
555
+ func (h * HugoSites ) printPathWarningsOnce () error {
556
+ h .printPathWarningsInit .Do (func () {
551
557
conf := h .Configs .Base
552
558
if conf .PrintPathWarnings {
553
559
// We need to do this before any post processing, as that may write to the same files twice
@@ -562,7 +568,14 @@ func (h *HugoSites) postRenderOnce() error {
562
568
return false
563
569
})
564
570
}
571
+ })
572
+ return nil
573
+ }
565
574
575
+ // / printUnusedTemplatesOnce prints unused templates if enabled.
576
+ func (h * HugoSites ) printUnusedTemplatesOnce () error {
577
+ h .printUnusedTemplatesInit .Do (func () {
578
+ conf := h .Configs .Base
566
579
if conf .PrintUnusedTemplates {
567
580
unusedTemplates := h .Tmpl ().(tpl.UnusedTemplatesProvider ).UnusedTemplates ()
568
581
for _ , unusedTemplate := range unusedTemplates {
0 commit comments