Repository: gohugoio/hugo (language: go)

Issue:
Improve --printPathWarnings when site calls templates.Defer
While working on the docs site I ran `hugo --printPathWarnings`. It shows duplicate target paths for every page. If I temporarily remove the `templates.Defer` wrapper in `layouts/_default/baseof.html` the warnings go away.

We addressed the same issue with `resources.PostProcess` in https://github.com/gohugoio/hugo/pull/11174. Perhaps we can do something similar here.


<details>
<summary>console output</summary>

WARN  Duplicate target paths: /404.html (2), /about/features/index.html (2), /about/index.html (2), /about/introduction/index.html (2), /about/license/index.html (2), /about/privacy/index.html (2), /about/security/index.html (2), /categories/index.html (2), /commands/hugo/index.html (2), /commands/hugo_build/index.html (2), /commands/hugo_completion/index.html (2), /commands/hugo_completion_bash/index.html (2), /commands/hugo_completion_fish/index.html (2), /commands/hugo_completion_powershell/index.html (2), /commands/hugo_completion_zsh/index.html (2), /commands/hugo_config/index.html (2), /commands/hugo_config_mounts/index.html (2), /commands/hugo_convert/index.html (2), /commands/hugo_convert_tojson/index.html (2), /commands/hugo_convert_totoml/index.html (2), /commands/hugo_convert_toyaml/index.html (2), /commands/hugo_deploy/index.html (2), /commands/hugo_env/index.html (2), /commands/hugo_gen/index.html (2), /commands/hugo_gen_chromastyles/index.html (2), /commands/hugo_gen_doc/index.html (2), /commands/hugo_gen_man/index.html (2), /commands/hugo_import/index.html (2), /commands/hugo_import_jekyll/index.html (2), /commands/hugo_list/index.html (2), /commands/hugo_list_all/index.html (2), /commands/hugo_list_drafts/index.html (2), /commands/hugo_list_expired/index.html (2), /commands/hugo_list_future/index.html (2), /commands/hugo_list_published/index.html (2), /commands/hugo_mod/index.html (2), /commands/hugo_mod_clean/index.html (2), /commands/hugo_mod_get/index.html (2), /commands/hugo_mod_graph/index.html (2), /commands/hugo_mod_init/index.html (2), /commands/hugo_mod_npm/index.html (2), /commands/hugo_mod_npm_pack/index.html (2), /commands/hugo_mod_tidy/index.html (2), /commands/hugo_mod_vendor/index.html (2), /commands/hugo_mod_verify/index.html (2), /commands/hugo_new/index.html (2), /commands/hugo_new_content/index.html (2), /commands/hugo_new_site/index.html (2), /commands/hugo_new_theme/index.html (2), /commands/hugo_server/index.html (2), /commands/hugo_server_trust/index.html (2), /commands/hugo_version/index.html (2), /commands/index.html (2), /configuration/all/index.html (2), /configuration/build/index.html (2), /configuration/caches/index.html (2), /configuration/cascade/index.html (2), /configuration/contenttypes/index.html (2), /configuration/deployment/index.html (2), /configuration/frontmatter/index.html (2), /configuration/httpcache/index.html (2), /configuration/imaging/index.html (2), /configuration/index.html (2), /configuration/introduction/index.html (2), /configuration/languages/index.html (2), /configuration/markup/index.html (2), /configuration/mediatypes/index.html (2), /configuration/menus/index.html (2), /configuration/minify/index.html (2), /configuration/module/index.html (2), /configuration/outputformats/index.html (2), /configuration/outputs/index.html (2), /configuration/page/index.html (2), /configuration/pagination/index.html (2), /configuration/params/index.html (2), /configuration/permalinks/index.html (2), /configuration/privacy/index.html (2), /configuration/related/index.html (2), /configuration/security/index.html (2), /configuration/segments/index.html (2), /configuration/server/index.html (2), /configuration/services/index.html (2), /configuration/sitemap/index.html (2), /configuration/taxonomies/index.html (2), /configuration/uglyurls/index.html (2), /content-management/archetypes/index.html (2), /content-management/build-options/index.html (2), /content-management/comments/index.html (2), /content-management/content-adapters/index.html (2), /content-management/data-sources/index.html (2), /content-management/diagrams/index.html (2), /content-management/formats/index.html (2), /content-management/front-matter/index.html (2), /content-management/image-processing/index.html (2), /content-management/index.html (2), /content-management/markdown-attributes/index.html (2), /content-management/mathematics/index.html (2), /content-management/menus/index.html (2), /content-management/multilingual/index.html (2), /content-management/organization/index.html (2), /content-management/page-bundles/index.html (2), /content-management/page-resources/index.html (2), /content-management/related/index.html (2), /content-management/sections/index.html (2), /content-management/shortcodes/index.html (2), /content-management/summaries/index.html (2), /content-management/syntax-highlighting/index.html (2), /content-management/taxonomies/index.html (2), /content-management/types/index.html (2), /content-management/urls/index.html (2), /contribute/development/index.html (2), /contribute/documentation/index.html (2), /contribute/index.html (2), /contribute/themes/index.html (2), /documentation/index.html (2), /functions/cast/index.html (2), /functions/cast/tofloat/index.html (2), /functions/cast/toint/index.html (2), /functions/cast/tostring/index.html (2), /functions/collections/after/index.html (2), /functions/collections/append/index.html (2), /functions/collections/apply/index.html (2), /functions/collections/complement/index.html (2), /functions/collections/delimit/index.html (2), /functions/collections/dictionary/index.html (2), /functions/collections/first/index.html (2), /functions/collections/group/index.html (2), /functions/collections/in/index.html (2), /functions/collections/index.html (2), /functions/collections/indexfunction/index.html (2), /functions/collections/intersect/index.html (2), /functions/collections/isset/index.html (2), /functions/collections/keyvals/index.html (2), /functions/collections/last/index.html (2), /functions/collections/merge/index.html (2), /functions/collections/newscratch/index.html (2), /functions/collections/querify/index.html (2), /functions/collections/reverse/index.html (2), /functions/collections/seq/index.html (2), /functions/collections/shuffle/index.html (2), /functions/collections/slice/index.html (2), /functions/collections/sort/index.html (2), /functions/collections/symdiff/index.html (2), /functions/collections/union/index.html (2), /functions/collections/uniq/index.html (2), /functions/collections/where/index.html (2), /functions/compare/conditional/index.html (2), /functions/compare/default/index.html (2), /functions/compare/eq/index.html (2), /functions/compare/ge/index.html (2), /functions/compare/gt/index.html (2), /functions/compare/index.html (2), /functions/compare/le/index.html (2), /functions/compare/lt/index.html (2), /functions/compare/ne/index.html (2), /functions/crypto/fnv32a/index.html (2), /functions/crypto/hmac/index.html (2), /functions/crypto/index.html (2), /functions/crypto/md5/index.html (2), /functions/crypto/sha1/index.html (2), /functions/crypto/sha256/index.html (2), /functions/css/index.html (2), /functions/css/postcss/index.html (2), /functions/css/sass/index.html (2), /functions/css/tailwindcss/index.html (2), /functions/data/getcsv/index.html (2), /functions/data/getjson/index.html (2), /functions/data/index.html (2), /functions/debug/dump/index.html (2), /functions/debug/index.html (2), /functions/debug/timer/index.html (2), /functions/diagrams/goat/index.html (2), /functions/diagrams/index.html (2), /functions/encoding/base64decode/index.html (2), /functions/encoding/base64encode/index.html (2), /functions/encoding/index.html (2), /functions/encoding/jsonify/index.html (2), /functions/fmt/errorf/index.html (2), /functions/fmt/erroridf/index.html (2), /functions/fmt/index.html (2), /functions/fmt/print/index.html (2), /functions/fmt/printf/index.html (2), /functions/fmt/println/index.html (2), /functions/fmt/warnf/index.html (2), /functions/fmt/warnidf/index.html (2), /functions/global/index.html (2), /functions/global/page/index.html (2), /functions/global/site/index.html (2), /functions/go-template/and/index.html (2), /functions/go-template/block/index.html (2), /functions/go-template/break/index.html (2), /functions/go-template/continue/index.html (2), /functions/go-template/define/index.html (2), /functions/go-template/else/index.html (2), /functions/go-template/end/index.html (2), /functions/go-template/if/index.html (2), /functions/go-template/index.html (2), /functions/go-template/len/index.html (2), /functions/go-template/not/index.html (2), /functions/go-template/or/index.html (2), /functions/go-template/range/index.html (2), /functions/go-template/return/index.html (2), /functions/go-template/template/index.html (2), /functions/go-template/try/index.html (2), /functions/go-template/urlquery/index.html (2), /functions/go-template/with/index.html (2), /functions/hash/fnv32a/index.html (2), /functions/hash/index.html (2), /functions/hash/xxhash/index.html (2), /functions/hugo/builddate/index.html (2), /functions/hugo/commithash/index.html (2), /functions/hugo/deps/index.html (2), /functions/hugo/environment/index.html (2), /functions/hugo/generator/index.html (2), /functions/hugo/goversion/index.html (2), /functions/hugo/index.html (2), /functions/hugo/isdevelopment/index.html (2), /functions/hugo/isextended/index.html (2), /functions/hugo/ismultihost/index.html (2), /functions/hugo/ismultilingual/index.html (2), /functions/hugo/isproduction/index.html (2), /functions/hugo/isserver/index.html (2), /functions/hugo/store/index.html (2), /functions/hugo/version/index.html (2), /functions/hugo/workingdir/index.html (2), /functions/images/autoorient/index.html (2), /functions/images/brightness/index.html (2), /functions/images/colorbalance/index.html (2), /functions/images/colorize/index.html (2), /functions/images/config/index.html (2), /functions/images/contrast/index.html (2), /functions/images/dither/index.html (2), /functions/images/filter/index.html (2), /functions/images/gamma/index.html (2), /functions/images/gaussianblur/index.html (2), /functions/images/grayscale/index.html (2), /functions/images/hue/index.html (2), /functions/images/index.html (2), /functions/images/invert/index.html (2), /functions/images/mask/index.html (2), /functions/images/opacity/index.html (2), /functions/images/overlay/index.html (2), /functions/images/padding/index.html (2), /functions/images/pixelate/index.html (2), /functions/images/process/index.html (2), /functions/images/qr/index.html (2), /functions/images/saturation/index.html (2), /functions/images/sepia/index.html (2), /functions/images/sigmoid/index.html (2), /functions/images/text/index.html (2), /functions/images/unsharpmask/index.html (2), /functions/index.html (2), /functions/inflect/humanize/index.html (2), /functions/inflect/index.html (2), /functions/inflect/pluralize/index.html (2), /functions/inflect/singularize/index.html (2), /functions/js/babel/index.html (2), /functions/js/batch/index.html (2), /functions/js/build/index.html (2), /functions/js/index.html (2), /functions/lang/formataccounting/index.html (2), /functions/lang/formatcurrency/index.html (2), /functions/lang/formatnumber/index.html (2), /functions/lang/formatnumbercustom/index.html (2), /functions/lang/formatpercent/index.html (2), /functions/lang/index.html (2), /functions/lang/merge/index.html (2), /functions/lang/translate/index.html (2), /functions/math/abs/index.html (2), /functions/math/acos/index.html (2), /functions/math/add/index.html (2), /functions/math/asin/index.html (2), /functions/math/atan/index.html (2), /functions/math/atan2/index.html (2), /functions/math/ceil/index.html (2), /functions/math/cos/index.html (2), /functions/math/counter/index.html (2), /functions/math/div/index.html (2), /functions/math/floor/index.html (2), /functions/math/index.html (2), /functions/math/log/index.html (2), /functions/math/max/index.html (2), /functions/math/min/index.html (2), /functions/math/mod/index.html (2), /functions/math/modbool/index.html (2), /functions/math/mul/index.html (2), /functions/math/pi/index.html (2), /functions/math/pow/index.html (2), /functions/math/product/index.html (2), /functions/math/rand/index.html (2), /functions/math/round/index.html (2), /functions/math/sin/index.html (2), /functions/math/sqrt/index.html (2), /functions/math/sub/index.html (2), /functions/math/sum/index.html (2), /functions/math/tan/index.html (2), /functions/math/todegrees/index.html (2), /functions/math/toradians/index.html (2), /functions/openapi3/index.html (2), /functions/openapi3/unmarshal/index.html (2), /functions/os/fileexists/index.html (2), /functions/os/getenv/index.html (2), /functions/os/index.html (2), /functions/os/readdir/index.html (2), /functions/os/readfile/index.html (2), /functions/os/stat/index.html (2), /functions/partials/include/index.html (2), /functions/partials/includecached/index.html (2), /functions/partials/index.html (2), /functions/path/base/index.html (2), /functions/path/basename/index.html (2), /functions/path/clean/index.html (2), /functions/path/dir/index.html (2), /functions/path/ext/index.html (2), /functions/path/index.html (2), /functions/path/join/index.html (2), /functions/path/split/index.html (2), /functions/reflect/index.html (2), /functions/reflect/ismap/index.html (2), /functions/reflect/isslice/index.html (2), /functions/resources/babel/index.html (2), /functions/resources/bytype/index.html (2), /functions/resources/concat/index.html (2), /functions/resources/copy/index.html (2), /functions/resources/executeastemplate/index.html (2), /functions/resources/fingerprint/index.html (2), /functions/resources/fromstring/index.html (2), /functions/resources/get/index.html (2), /functions/resources/getmatch/index.html (2), /functions/resources/getremote/index.html (2), /functions/resources/index.html (2), /functions/resources/match/index.html (2), /functions/resources/minify/index.html (2), /functions/resources/postcss/index.html (2), /functions/resources/postprocess/index.html (2), /functions/resources/tocss/index.html (2), /functions/safe/css/index.html (2), /functions/safe/html/index.html (2), /functions/safe/htmlattr/index.html (2), /functions/safe/index.html (2), /functions/safe/js/index.html (2), /functions/safe/jsstr/index.html (2), /functions/safe/url/index.html (2), /functions/strings/chomp/index.html (2), /functions/strings/contains/index.html (2), /functions/strings/containsany/index.html (2), /functions/strings/containsnonspace/index.html (2), /functions/strings/count/index.html (2), /functions/strings/countrunes/index.html (2), /functions/strings/countwords/index.html (2), /functions/strings/diff/index.html (2), /functions/strings/findre/index.html (2), /functions/strings/findresubmatch/index.html (2), /functions/strings/firstupper/index.html (2), /functions/strings/hasprefix/index.html (2), /functions/strings/hassuffix/index.html (2), /functions/strings/index.html (2), /functions/strings/repeat/index.html (2), /functions/strings/replace/index.html (2), /functions/strings/replacere/index.html (2), /functions/strings/runecount/index.html (2), /functions/strings/slicestring/index.html (2), /functions/strings/split/index.html (2), /functions/strings/substr/index.html (2), /functions/strings/title/index.html (2), /functions/strings/tolower/index.html (2), /functions/strings/toupper/index.html (2), /functions/strings/trim/index.html (2), /functions/strings/trimleft/index.html (2), /functions/strings/trimprefix/index.html (2), /functions/strings/trimright/index.html (2), /functions/strings/trimspace/index.html (2), /functions/strings/trimsuffix/index.html (2), /functions/strings/truncate/index.html (2), /functions/templates/defer/index.html (2), /functions/templates/exists/index.html (2), /functions/templates/index.html (2), /functions/time/astime/index.html (2), /functions/time/duration/index.html (2), /functions/time/format/index.html (2), /functions/time/index.html (2), /functions/time/now/index.html (2), /functions/time/parseduration/index.html (2), /functions/transform/canhighlight/index.html (2), /functions/transform/emojify/index.html (2), /functions/transform/highlight/index.html (2), /functions/transform/highlightcodeblock/index.html (2), /functions/transform/htmlescape/index.html (2), /functions/transform/htmlunescape/index.html (2), /functions/transform/index.html (2), /functions/transform/markdownify/index.html (2), /functions/transform/plainify/index.html (2), /functions/transform/remarshal/index.html (2), /functions/transform/tomath/index.html (2), /functions/transform/unmarshal/index.html (2), /functions/transform/xmlescape/index.html (2), /functions/urls/abslangurl/index.html (2), /functions/urls/absurl/index.html (2), /functions/urls/anchorize/index.html (2), /functions/urls/index.html (2), /functions/urls/joinpath/index.html (2), /functions/urls/parse/index.html (2), /functions/urls/ref/index.html (2), /functions/urls/rellangurl/index.html (2), /functions/urls/relref/index.html (2), /functions/urls/relurl/index.html (2), /functions/urls/urlize/index.html (2), /getting-started/directory-structure/index.html (2), /getting-started/external-learning-resources/index.html (2), /getting-started/index.html (2), /getting-started/quick-start/index.html (2), /getting-started/usage/index.html (2), /hosting-and-deployment/deployment-with-rclone/index.html (2), /hosting-and-deployment/deployment-with-rsync/index.html (2), /hosting-and-deployment/hosting-on-21yunbox/index.html (2), /hosting-and-deployment/hosting-on-aws-amplify/index.html (2), /hosting-and-deployment/hosting-on-azure-static-web-apps/index.html (2), /hosting-and-deployment/hosting-on-cloudflare-pages/index.html (2), /hosting-and-deployment/hosting-on-firebase/index.html (2), /hosting-and-deployment/hosting-on-github/index.html (2), /hosting-and-deployment/hosting-on-gitlab/index.html (2), /hosting-and-deployment/hosting-on-keycdn/index.html (2), /hosting-and-deployment/hosting-on-netlify/index.html (2), /hosting-and-deployment/hosting-on-render/index.html (2), /hosting-and-deployment/hugo-deploy/index.html (2), /hosting-and-deployment/index.html (2), /hugo-modules/index.html (2), /hugo-modules/introduction/index.html (2), /hugo-modules/theme-components/index.html (2), /hugo-modules/use-modules/index.html (2), /hugo-pipes/bundling/index.html (2), /hugo-pipes/fingerprint/index.html (2), /hugo-pipes/index.html (2), /hugo-pipes/introduction/index.html (2), /hugo-pipes/js/index.html (2), /hugo-pipes/minification/index.html (2), /hugo-pipes/postcss/index.html (2), /hugo-pipes/postprocess/index.html (2), /hugo-pipes/resource-from-string/index.html (2), /hugo-pipes/resource-from-template/index.html (2), /hugo-pipes/transpile-sass-to-css/index.html (2), /index.html (2), /installation/bsd/index.html (2), /installation/index.html (2), /installation/linux/index.html (2), /installation/macos/index.html (2), /installation/windows/index.html (2), /methods/duration/abs/index.html (2), /methods/duration/hours/index.html (2), /methods/duration/index.html (2), /methods/duration/microseconds/index.html (2), /methods/duration/milliseconds/index.html (2), /methods/duration/minutes/index.html (2), /methods/duration/nanoseconds/index.html (2), /methods/duration/round/index.html (2), /methods/duration/seconds/index.html (2), /methods/duration/truncate/index.html (2), /methods/index.html (2), /methods/menu-entry/children/index.html (2), /methods/menu-entry/haschildren/index.html (2), /methods/menu-entry/identifier/index.html (2), /methods/menu-entry/index.html (2), /methods/menu-entry/keyname/index.html (2), /methods/menu-entry/menu/index.html (2), /methods/menu-entry/name/index.html (2), /methods/menu-entry/page/index.html (2), /methods/menu-entry/pageref/index.html (2), /methods/menu-entry/params/index.html (2), /methods/menu-entry/parent/index.html (2), /methods/menu-entry/post/index.html (2), /methods/menu-entry/pre/index.html (2), /methods/menu-entry/title/index.html (2), /methods/menu-entry/url/index.html (2), /methods/menu-entry/weight/index.html (2), /methods/menu/byname/index.html (2), /methods/menu/byweight/index.html (2), /methods/menu/index.html (2), /methods/menu/limit/index.html (2), /methods/menu/reverse/index.html (2), /methods/page/aliases/index.html (2), /methods/page/alltranslations/index.html (2), /methods/page/alternativeoutputformats/index.html (2), /methods/page/ancestors/index.html (2), /methods/page/bundletype/index.html (2), /methods/page/codeowners/index.html (2), /methods/page/content/index.html (2), /methods/page/contentwithoutsummary/index.html (2), /methods/page/currentsection/index.html (2), /methods/page/data/index.html (2), /methods/page/date/index.html (2), /methods/page/description/index.html (2), /methods/page/draft/index.html (2), /methods/page/eq/index.html (2), /methods/page/expirydate/index.html (2), /methods/page/file/index.html (2), /methods/page/firstsection/index.html (2), /methods/page/fragments/index.html (2), /methods/page/fuzzywordcount/index.html (2), /methods/page/getpage/index.html (2), /methods/page/getterms/index.html (2), /methods/page/gitinfo/index.html (2), /methods/page/hasmenucurrent/index.html (2), /methods/page/hasshortcode/index.html (2), /methods/page/headingsfiltered/index.html (2), /methods/page/index.html (2), /methods/page/insection/index.html (2), /methods/page/isancestor/index.html (2), /methods/page/isdescendant/index.html (2), /methods/page/ishome/index.html (2), /methods/page/ismenucurrent/index.html (2), /methods/page/isnode/index.html (2), /methods/page/ispage/index.html (2), /methods/page/issection/index.html (2), /methods/page/istranslated/index.html (2), /methods/page/keywords/index.html (2), /methods/page/kind/index.html (2), /methods/page/language/index.html (2), /methods/page/lastmod/index.html (2), /methods/page/layout/index.html (2), /methods/page/len/index.html (2), /methods/page/linktitle/index.html (2), /methods/page/next/index.html (2), /methods/page/nextinsection/index.html (2), /methods/page/outputformats/index.html (2), /methods/page/page/index.html (2), /methods/page/pages/index.html (2), /methods/page/paginate/index.html (2), /methods/page/paginator/index.html (2), /methods/page/param/index.html (2), /methods/page/params/index.html (2), /methods/page/parent/index.html (2), /methods/page/path/index.html (2), /methods/page/permalink/index.html (2), /methods/page/plain/index.html (2), /methods/page/plainwords/index.html (2), /methods/page/prev/index.html (2), /methods/page/previnsection/index.html (2), /methods/page/publishdate/index.html (2), /methods/page/rawcontent/index.html (2), /methods/page/readingtime/index.html (2), /methods/page/ref/index.html (2), /methods/page/regularpages/index.html (2), /methods/page/regularpagesrecursive/index.html (2), /methods/page/relpermalink/index.html (2), /methods/page/relref/index.html (2), /methods/page/render/index.html (2), /methods/page/rendershortcodes/index.html (2), /methods/page/renderstring/index.html (2), /methods/page/resources/index.html (2), /methods/page/scratch/index.html (2), /methods/page/section/index.html (2), /methods/page/sections/index.html (2), /methods/page/site/index.html (2), /methods/page/sitemap/index.html (2), /methods/page/sites/index.html (2), /methods/page/slug/index.html (2), /methods/page/store/index.html (2), /methods/page/summary/index.html (2), /methods/page/tableofcontents/index.html (2), /methods/page/title/index.html (2), /methods/page/translationkey/index.html (2), /methods/page/translations/index.html (2), /methods/page/truncated/index.html (2), /methods/page/type/index.html (2), /methods/page/weight/index.html (2), /methods/page/wordcount/index.html (2), /methods/pager/first/index.html (2), /methods/pager/hasnext/index.html (2), /methods/pager/hasprev/index.html (2), /methods/pager/index.html (2), /methods/pager/last/index.html (2), /methods/pager/next/index.html (2), /methods/pager/numberofelements/index.html (2), /methods/pager/pagegroups/index.html (2), /methods/pager/pagenumber/index.html (2), /methods/pager/pagers/index.html (2), /methods/pager/pagersize/index.html (2), /methods/pager/pages/index.html (2), /methods/pager/pagesize/index.html (2), /methods/pager/prev/index.html (2), /methods/pager/totalnumberofelements/index.html (2), /methods/pager/totalpages/index.html (2), /methods/pager/url/index.html (2), /methods/pages/bydate/index.html (2), /methods/pages/byexpirydate/index.html (2), /methods/pages/bylanguage/index.html (2), /methods/pages/bylastmod/index.html (2), /methods/pages/bylength/index.html (2), /methods/pages/bylinktitle/index.html (2), /methods/pages/byparam/index.html (2), /methods/pages/bypublishdate/index.html (2), /methods/pages/bytitle/index.html (2), /methods/pages/byweight/index.html (2), /methods/pages/groupby/index.html (2), /methods/pages/groupbydate/index.html (2), /methods/pages/groupbyexpirydate/index.html (2), /methods/pages/groupbylastmod/index.html (2), /methods/pages/groupbyparam/index.html (2), /methods/pages/groupbyparamdate/index.html (2), /methods/pages/groupbypublishdate/index.html (2), /methods/pages/index.html (2), /methods/pages/len/index.html (2), /methods/pages/limit/index.html (2), /methods/pages/next/index.html (2), /methods/pages/prev/index.html (2), /methods/pages/related/index.html (2), /methods/pages/reverse/index.html (2), /methods/resource/colors/index.html (2), /methods/resource/content/index.html (2), /methods/resource/crop/index.html (2), /methods/resource/data/index.html (2), /methods/resource/err/index.html (2), /methods/resource/exif/index.html (2), /methods/resource/fill/index.html (2), /methods/resource/filter/index.html (2), /methods/resource/fit/index.html (2), /methods/resource/height/index.html (2), /methods/resource/index.html (2), /methods/resource/mediatype/index.html (2), /methods/resource/name/index.html (2), /methods/resource/params/index.html (2), /methods/resource/permalink/index.html (2), /methods/resource/process/index.html (2), /methods/resource/publish/index.html (2), /methods/resource/relpermalink/index.html (2), /methods/resource/resize/index.html (2), /methods/resource/resourcetype/index.html (2), /methods/resource/title/index.html (2), /methods/resource/width/index.html (2), /methods/shortcode/get/index.html (2), /methods/shortcode/index.html (2), /methods/shortcode/inner/index.html (2), /methods/shortcode/innerdeindent/index.html (2), /methods/shortcode/isnamedparams/index.html (2), /methods/shortcode/name/index.html (2), /methods/shortcode/ordinal/index.html (2), /methods/shortcode/page/index.html (2), /methods/shortcode/params/index.html (2), /methods/shortcode/parent/index.html (2), /methods/shortcode/position/index.html (2), /methods/shortcode/ref/index.html (2), /methods/shortcode/relref/index.html (2), /methods/shortcode/scratch/index.html (2), /methods/shortcode/site/index.html (2), /methods/shortcode/store/index.html (2), /methods/site/allpages/index.html (2), /methods/site/baseurl/index.html (2), /methods/site/builddrafts/index.html (2), /methods/site/config/index.html (2), /methods/site/copyright/index.html (2), /methods/site/data/index.html (2), /methods/site/disqusshortname/index.html (2), /methods/site/getpage/index.html (2), /methods/site/googleanalytics/index.html (2), /methods/site/home/index.html (2), /methods/site/index.html (2), /methods/site/isdevelopment/index.html (2), /methods/site/ismultilingual/index.html (2), /methods/site/isserver/index.html (2), /methods/site/language/index.html (2), /methods/site/languageprefix/index.html (2), /methods/site/languages/index.html (2), /methods/site/lastchange/index.html (2), /methods/site/lastmod/index.html (2), /methods/site/mainsections/index.html (2), /methods/site/menus/index.html (2), /methods/site/pages/index.html (2), /methods/site/param/index.html (2), /methods/site/params/index.html (2), /methods/site/regularpages/index.html (2), /methods/site/sections/index.html (2), /methods/site/sites/index.html (2), /methods/site/store/index.html (2), /methods/site/taxonomies/index.html (2), /methods/site/title/index.html (2), /methods/taxonomy/alphabetical/index.html (2), /methods/taxonomy/bycount/index.html (2), /methods/taxonomy/count/index.html (2), /methods/taxonomy/get/index.html (2), /methods/taxonomy/index.html (2), /methods/taxonomy/page/index.html (2), /methods/time/add/index.html (2), /methods/time/adddate/index.html (2), /methods/time/after/index.html (2), /methods/time/before/index.html (2), /methods/time/day/index.html (2), /methods/time/equal/index.html (2), /methods/time/format/index.html (2), /methods/time/hour/index.html (2), /methods/time/index.html (2), /methods/time/isdst/index.html (2), /methods/time/iszero/index.html (2), /methods/time/local/index.html (2), /methods/time/minute/index.html (2), /methods/time/month/index.html (2), /methods/time/nanosecond/index.html (2), /methods/time/round/index.html (2), /methods/time/second/index.html (2), /methods/time/sub/index.html (2), /methods/time/truncate/index.html (2), /methods/time/unix/index.html (2), /methods/time/unixmicro/index.html (2), /methods/time/unixmilli/index.html (2), /methods/time/unixnano/index.html (2), /methods/time/utc/index.html (2), /methods/time/weekday/index.html (2), /methods/time/year/index.html (2), /methods/time/yearday/index.html (2), /news/index.html (2), /quick-reference/emojis/index.html (2), /quick-reference/functions/index.html (2), /quick-reference/glossary/index.html (2), /quick-reference/index.html (2), /quick-reference/methods/index.html (2), /quick-reference/page-collections/index.html (2), /render-hooks/blockquotes/index.html (2), /render-hooks/code-blocks/index.html (2), /render-hooks/headings/index.html (2), /render-hooks/images/index.html (2), /render-hooks/index.html (2), /render-hooks/introduction/index.html (2), /render-hooks/links/index.html (2), /render-hooks/passthrough/index.html (2), /render-hooks/tables/index.html (2), /shortcodes/details/index.html (2), /shortcodes/figure/index.html (2), /shortcodes/gist/index.html (2), /shortcodes/highlight/index.html (2), /shortcodes/index.html (2), /shortcodes/instagram/index.html (2), /shortcodes/param/index.html (2), /shortcodes/qr/index.html (2), /shortcodes/ref/index.html (2), /shortcodes/relref/index.html (2), /shortcodes/vimeo/index.html (2), /shortcodes/x/index.html (2), /shortcodes/youtube/index.html (2), /showcase/1password-support/index.html (2), /showcase/alora-labs/index.html (2), /showcase/ampio-help/index.html (2), /showcase/bypasscensorship/index.html (2), /showcase/digitalgov/index.html (2), /showcase/fireship/index.html (2), /showcase/forestry/index.html (2), /showcase/godot-tutorials/index.html (2), /showcase/hapticmedia/index.html (2), /showcase/hartwell-insurance/index.html (2), /showcase/keycdn/index.html (2), /showcase/letsencrypt/index.html (2), /showcase/linode/index.html (2), /showcase/overmindstudios/index.html (2), /showcase/pharmaseal/index.html (2), /showcase/quiply-employee-communications-app/index.html (2), /showcase/template/index.html (2), /showcase/tomango/index.html (2), /tags/index.html (2), /templates/404/index.html (2), /templates/base/index.html (2), /templates/content-view/index.html (2), /templates/embedded/index.html (2), /templates/home/index.html (2), /templates/index.html (2), /templates/introduction/index.html (2), /templates/lookup-order/index.html (2), /templates/menu/index.html (2), /templates/output-formats/index.html (2), /templates/pagination/index.html (2), /templates/partial/index.html (2), /templates/robots/index.html (2), /templates/rss/index.html (2), /templates/section/index.html (2), /templates/shortcode/index.html (2), /templates/single/index.html (2), /templates/sitemap/index.html (2), /templates/taxonomy/index.html (2), /templates/term/index.html (2), /templates/types/index.html (2), /tools/editors/index.html (2), /tools/front-ends/index.html (2), /tools/index.html (2), /tools/migrations/index.html (2), /tools/other/index.html (2), /tools/search/index.html (2), /troubleshooting/audit/index.html (2), /troubleshooting/deprecation/index.html (2), /troubleshooting/faq/index.html (2), /troubleshooting/index.html (2), /troubleshooting/inspection/index.html (2), /troubleshooting/logging/index.html (2), /troubleshooting/performance/index.html (2)

</details>




Discussion / hints:
I'm guessing I introduced this in eb7a5aabaaa025b6633b4aff3267b21ebdffb8e9 ... ordering things are tricky.

Fix patch:
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go
index 83e8caa7f48..b17c761aa74 100644
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -85,7 +85,8 @@ type HugoSites struct {
 
 	pageTrees *pageTrees
 
-	postRenderInit sync.Once
+	printUnusedTemplatesInit sync.Once
+	printPathWarningsInit    sync.Once
 
 	// File change events with filename stored in this map will be skipped.
 	skipRebuildForFilenamesMu sync.Mutex
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index 44598526cbf..729c17c7528 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -176,12 +176,18 @@ func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
 			return err
 		}
 
+		// We need to do this before render deferred.
+		if err := h.printPathWarningsOnce(); err != nil {
+			h.SendError(fmt.Errorf("printPathWarnings: %w", err))
+		}
+
 		if err := h.renderDeferred(infol); err != nil {
 			h.SendError(fmt.Errorf("renderDeferred: %w", err))
 		}
 
-		if err := h.postRenderOnce(); err != nil {
-			h.SendError(fmt.Errorf("postRenderOnce: %w", err))
+		// This needs to be done after the deferred rendering to get complete template usage coverage.
+		if err := h.printUnusedTemplatesOnce(); err != nil {
+			h.SendError(fmt.Errorf("printPathWarnings: %w", err))
 		}
 
 		if err := h.postProcess(infol); err != nil {
@@ -545,9 +551,9 @@ func (s *Site) executeDeferredTemplates(de *deps.DeferredExecutions) error {
 	return g.Wait()
 }
 
-// / postRenderOnce runs some post processing that only needs to be done once, e.g. printing of unused templates.
-func (h *HugoSites) postRenderOnce() error {
-	h.postRenderInit.Do(func() {
+// printPathWarningsOnce prints path warnings if enabled.
+func (h *HugoSites) printPathWarningsOnce() error {
+	h.printPathWarningsInit.Do(func() {
 		conf := h.Configs.Base
 		if conf.PrintPathWarnings {
 			// 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 {
 				return false
 			})
 		}
+	})
+	return nil
+}
 
+// / printUnusedTemplatesOnce prints unused templates if enabled.
+func (h *HugoSites) printUnusedTemplatesOnce() error {
+	h.printUnusedTemplatesInit.Do(func() {
+		conf := h.Configs.Base
 		if conf.PrintUnusedTemplates {
 			unusedTemplates := h.Tmpl().(tpl.UnusedTemplatesProvider).UnusedTemplates()
 			for _, unusedTemplate := range unusedTemplates {


Test patch: