Hugo Release 0.69.0

Post Build Resource Transformations

Hugo 0.69.0 allows you to delay resource processing to after the build, the prime use case being removal of unused CSS.

April 10, 2020

Go to Hugo Releases for the release downloads.

Featured Image for Post Build Resource Transformations

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: