tpl/resources: Deprecate resources.PostProcess in favour of templates.Defer

Fixes #15086
This commit is contained in:
Bjørn Erik Pedersen
2026-07-04 15:59:18 +02:00
parent 7b4ddd1863
commit 29ed932513
2 changed files with 23 additions and 0 deletions
+4
View File
@@ -20,6 +20,7 @@ import (
"fmt"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/resources/postpub"
@@ -293,6 +294,9 @@ func (ns *Namespace) Minify(r resources.ResourceTransformer) (resource.Resource,
}
// PostProcess processes r after the build.
//
// Deprecated: Use templates.Defer instead.
func (ns *Namespace) PostProcess(r resource.Resource) (postpub.PostPublishedResource, error) {
hugo.DeprecateWithLogger("resources.PostProcess", "Use templates.Defer instead. See https://gohugo.io/functions/templates/defer/", "v0.164.0", ns.deps.Log.Logger())
return ns.deps.ResourceSpec.PostProcess(r)
}
@@ -277,3 +277,22 @@ disableKinds = ['page','section','rss','sitemap','taxonomy','term']
)
b.AssertLogContains("! WARN Dart Sass: hugo:vars")
}
// See issue 15086.
func TestPostProcessDeprecated(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ["taxonomy", "term", "section", "RSS", "sitemap", "robotsTXT", "404"]
-- assets/css/main.css --
body { color: red; }
-- layouts/home.html --
{{ $r := resources.Get "css/main.css" | minify | resources.PostProcess }}
{{ $r.RelPermalink }}
`
b := hugolib.Test(t, files, hugolib.TestOptInfo())
b.AssertLogContains("resources.PostProcess was deprecated in Hugo v0.164.0")
}