Repository: gohugoio/hugo (language: go)

Issue:
--printUnusedTemplates  has some false positives
It seems that we print those before we execute any `deferred` template.


Discussion / hints:

Fix patch:
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index e066aa1009a..44598526cbf 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -170,10 +170,6 @@ func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
 			h.SendError(fmt.Errorf("render: %w", err))
 		}
 
-		if err := h.postRenderOnce(); err != nil {
-			h.SendError(fmt.Errorf("postRenderOnce: %w", err))
-		}
-
 		// Make sure to write any build stats to disk first so it's available
 		// to the post processors.
 		if err := h.writeBuildStats(); err != nil {
@@ -184,6 +180,10 @@ func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
 			h.SendError(fmt.Errorf("renderDeferred: %w", err))
 		}
 
+		if err := h.postRenderOnce(); err != nil {
+			h.SendError(fmt.Errorf("postRenderOnce: %w", err))
+		}
+
 		if err := h.postProcess(infol); err != nil {
 			h.SendError(fmt.Errorf("postProcess: %w", err))
 		}


Test patch: