github gohugoio/hugo v0.112.0

latest releases: v0.138.0, v0.137.1, v0.137.0...
17 months ago

Note: There's a patch release out already, see https://github.com/gohugoio/hugo/releases/tag/v0.112.1

Proper TailwindCSS v3.x support, much improved language config merge, consolidation of all Hugo config (check out hugo config), rewritten commands package (CLI) using SimpleCobra, Goldmark's typographer extension (quotation marks per language), and more.

Headlines

TailwindCSS v3.x Support, new cache buster configuration

See https://github.com/bep/hugo-starter-tailwind-basic for a running example.

TailwindCSS 3 has been out for a while now, and unfortunately their new build strategy didn't work very well with Hugo. But this release adds a new build.cachebusters config option for the resource cache that allows more fine grained control over when to trigger a new Tailwind build. This is a generally useful feature, so if you're having issues not seeing your resource changes (e.g. change to a JS file) on change, you could try to tweak the defaults. A tip is to run the server with hugo server --debug and watch out for log messages prefixed with cachebuster: on file changes.

There are several possible setups here, but one that we have tested and that works well is outlined in the config below. The basic concept is to add hugo_stats.json to the server watcher list in Hugo and trigger a new TailwindCSS build only whenever either this file or the main CSS file changes.

[module]
  [[module.mounts]]
    source = "assets"
    target = "assets"
  [[module.mounts]]
    source = "hugo_stats.json"
    target = "assets/watching/hugo_stats.json"

[build]
  writeStats = true
  [[build.cachebusters]]
    source = "assets/watching/hugo_stats\\.json"
    target = "styles\\.css"
  [[build.cachebusters]]
    source = "(postcss|tailwind)\\.config\\.js"
    target = "css"
  [[build.cachebusters]]
    source = "assets/.*\\.(js|ts|jsx|tsx)"
    target = "js"
  [[build.cachebusters]]
    source = "assets/.*\\.(.*)$"
    target = "$1"

And then in tailwind.config.js:

module.exports = {
	content: ['./hugo_stats.json'],
};

Reconsolidated all configuration handling

For this release we have collected all configuration into one big Go struct and rewritten the command line API using SimpleCobra. All of this makes the source code easier to maintain and understand, but the original motivation for this was to get a complete and autogenerated API reference for Hugo (we're working on getting that done), but this also have some less technical upsides:

'hugo config' is now complete

What you get when running hugo config is a complete TOML representation (add --format json or --format yaml for alternative formats) of the effective configuration. As this will include default values and configuration merged in from themes, we don't recommend to copy and paste this into hugo.toml, as that would make your configuration very verbose.

Improved language config handling

See issue #10620 for some details, but in general, the merge behaviour of sections from languages is much improved. In the example below for language en you will now get:

 "comments": {
    "color": "blue",
    "title": "English Comments Title",
}

In earlier versions of Hugo you would get:

 "comments": {
    "title": "English Comments Title",
}
title = "Base Title"
staticDir = "mystatic"
[params]
[params.comments]
color = "blue"
title = "Default Comments Title"
[languages]
[languages.en]
title = "English Title"
[languages.en.params.comments]
title = "English Comments Title"

Note that values in a given language will always have precedence over same keys in root (the section inside the language is the receiving side of any merge operation), so, if you want the old (and buggy) behaviour, you can add a merge strategy to one of the params sections, e.g:

[languages.en.params.comments]
_merge = "none"
title = "English Comments Title"

You can now also configure just about everything per language. One useful example would be the Goldmark typographer extension:

[languages.de]
languageCode = 'de-DE'
languageName = 'Deutsch'
weight = 2
[languages.de.markup.goldmark.extensions.typographer]
leftDoubleQuote = '«'   # default “
rightDoubleQuote = '»'  # default ”

More info in verbose build output

If you build flag with the -v, you will now get timing info for the core building steps in Hugo:

INFO 2023/05/16 09:53:55 process in 17 ms
INFO 2023/05/16 09:53:55 assemble in 345 ms
INFO 2023/05/16 09:53:55 render in 341 ms
INFO 2023/05/16 09:53:55 postProcess in 0 ms

Notes

Bug fixes

Improvements

Dependency Updates

Documentation

Don't miss a new hugo release

NewReleases is sending notifications on new releases.