ec0abe052 Update index.md ed44339cd Update bio.md cef04eb95 Minor edits 4d45dcc8d Submitting Digital.gov to the Hugo Showcase d35126af7 Azure uses storage containers, not buckets; edited accordingly. (#1078) 9c249cc89 fix grammatical error 9728699a3 Release Hugo 0.69.2 cccabed0c Merge branch 'temp692' 3d0a740c4 releaser: Add release notes to /docs for release of 0.69.2 b760aceb1 HTTPS external links in docs 49e4631b0 Release 0.69.1 01f3da870 Merge branch 'temp691' 8280d85aa releaser: Add release notes to /docs for release of 0.69.1 40ea44d24 fix typo (#1088) 725f53643 Rebuild cache 80ee1efd9 Add KeyCDN Showcase f253e906e docs: Fix typo in Hugo's Security Model b3ffd1ad3 Mentioning a range is equivalent to foreach (#1086) 0c396911f Update jsonify function docs 376befc9a Fix typo (#1084) 4bdc9bc72 Mark .Page.UniqueID as deprecated and add .File.UniqueID 30a7b7bf2 Update hosting-on-github.md c5db4ba2b Update postprocess.md 1121f74a5 Update install guide with Scoop extended 8988aa6fa Merge branch 'postprocess' 225d3f9c7 Release Hugo 0.69.0 4caf7a89a releaser: Add release notes to /docs for release of 0.69.0 664b2a0fa Document resources.PostProcess and buildStats 9737b34e9 docs: Regen docs helper 0fab3ba24 Merge commit 'da3c3e5fbd0de65f956618cd2e35401460a3cd02' 96dad83b1 Update hosting-on-aws-amplify.md 57eb27897 Merge commit 'c494c37a4523fbf2db6274dc87e0877fd5bec24b' dcc7afef7 fix typo in getting started git-subtree-dir: docs git-subtree-split: ec0abe052bcfebc65c323df4ff14ad277bb405d8
6.8 KiB
date: 2020-04-10 title: "Post Build Resource Transformations" description: "Hugo 0.69.0 allows you to delay resource processing to after the build, the prime use case being removal of unused CSS." categories: ["Releases"]
It's Eeaster, a time for mysteries and puzzles. And at first glance, this Hugo release looks a little mysterious. The core of if is a mind-twister:
{{ $css := resources.Get "css/main.css" }}
{{ $css = $css | resources.PostCSS }}
{{ if hugo.IsProduction }}
{{ $css = $css | minify | fingerprint | resources.PostProcess }}
{{ end }}
<link href="{{ $css.RelPermalink }}" rel="stylesheet" />
The above uses the new resources.PostProcess template function which tells Hugo to postpone the transformation of the Hugo Pipes chain to after the build, allowing the build steps to use the build output in /public
as part of its processing.
The prime current use case for the above is CSS pruning in PostCSS. In simple cases you can use the templates as a base for the content filters, but that has its limitations and can be very hard to setup, especially in themed configurations. So we have added a new writeStats configuration that, when enabled, will write a file named hugo_stats.json
to your project root with some aggregated data about the build, e.g. list of HTML entities published, to be used to do CSS pruning.
This release represents 20 contributions by 10 contributors to the main Hugo code base.@bep leads the Hugo development with a significant amount of contributions, but also a big shoutout to @moorereason, @jaywilliams, and @satotake for their ongoing contributions. And a big thanks to @digitalcraftsman and @onedrawingperday for their relentless work on keeping the themes site in pristine condition and to @davidsneighbour and @kaushalmodi for all the great work on the documentation site.
Many have also been busy writing and fixing the documentation in hugoDocs, which has received 14 contributions by 7 contributors. A special thanks to @bep, @coliff, @dmgawel, and @jasikpark for their work on the documentation site.
Hugo now has:
- 43052+ stars
- 438+ contributors
- 302+ themes
Enhancements
Templates
- Extend Jsonify to support options map 8568928a @moorereason
- Extend Jsonify to support optional indent parameter 1bc93021 @moorereason #5040
Other
- Regen docs helper b7ff4dc2 @bep
- Collect HTML elements during the build to use in PurgeCSS etc. 095bf64c @bep #6999
- Update to latest emoji package 7791a804 @QuLogic
- Update hosting-on-aws-amplify.md c774b230 @Helicer
- Add basic "post resource publish support" 2f721f8e @bep #7146
- Typo correction 7eba37ae @fekete-robert
- Use semver for min_version per recommendations efc61d6f @jaywilliams
- Updateto gitmap v1.1.2 4de3ecdc @dragtor #6985
- Add data context to the key in ExecuteAsTemplate" c9dc316a @bep #7064
Fixes
Other
- Fix hugo mod vendor for regular file mounts d8d6a25b @bep #7140
- Revert "Revert "common/herrors: Fix typos in comments"" 9f12be54 @bep
- Fix typos in comments" 4437e918 @bep
- Fix typos in comments 1123711b @rnazmo
- Fix TrimShortHTML 9c998753 @satotake #7081
- Fix IsDescendant/IsAncestor for overlapping section names 4a39564e @bep #7096
- fix typo in getting started b6e097cf @matrixise
- Fix _build.list.local logic 523d5194 @bep #7089
- Fix cache reset for a page's collections on server live reload cfa73050 @bep #7085