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
- openapi2: .ExtensionProps is now .Extensions and just a map.
- We have deprecated
site.Language.Params
and configuration of custom params outside of the language[params]
, see https://gohugo.io/content-management/multilingual/#changes-in-hugo-01120 for more information.
Bug fixes
- Fix "unknown command" message when no suggestion 288be19 @bep #10953
- commands: Fix build logic when listing expired/future draft content e6dc805 @bep #10972
- commands: Fix data race 0a51dfa @bep #10953
- tpl/urls: Fix build broken by a merge e4e0313 @bep
- Fix warn message about custom params on the language top level ad4bc96 @deining
- Fix some spelling mistakes 4003c79 @cuishuang
- all: Fix comments for exported functions and packages 610ceda @alexandear
- modules: Fix format flag in error 95818e2 @alexandear
- Fix some recently introduced error handling issues 834b3d7 @bep #10953
- Re-add site.LanguagePrefix 86b2a27 @bep #10947
- Deprecate site.Language.Params and some other fixes 5d85716 @bep #10947
- readme: Fix build command d01731d @kirisakow
- resources: Fix typos in error message and variables 891b291 @alexandear
- commands: Fix data race in test 0fbab7c @bep
Improvements
- circleci: Add github.com to known hosts 70b2aaf @bep
- Add --format to hugo config 85b13c1 @bep
- postcss: Improve validation of option 'config' 9a0370e @deining
- Avoid writing to hugo_stats.json when there are no changes 4cac5f5 @bep #10985
- Add cache busting config to support Tailwind 3 2c3d4df @bep #10974
- commands: Make all list commands list what 'all' did before 6ca8a40 @bep #10953
- tpl/tplimpl: Add img loading attribute to figure shortcode (#10927) 2db7ec6 @InLaw
- Allow whitelisting mediaTypes used in resources.GetRemote 2637b4e @bep #10286
- Add hugo.WorkingDir 7c7baa6 @bep #10969
- Make language merging of markup etc. config without values in the root 4f085e8 @bep #10953
- tpl/urls: Return empty string when JoinPath has zero args 150d190 @jmooring
- Re-add --printUnusedTemplates and --printPathWarnings d6197a4 @bep #10953
- tpl/urls: Add JoinPath template function 5b3e165 @jmooring #9694
- Allow legacy taxonomyTerm in disableKinds 03cb38e @bep #10953
- Make GOMAXPROCS to be CPU limit aware 008170c @BenTheElder #10950
- Allow empty params.mainSections 7c647bc @bep #10953
- commands: Load config before creating the filesystem 3f00f47 @bep
- github: Trim the test flow a little 35955f5 @bep
- commands: Improve the common build flag handling 8a69ccb @bep #10947
- Support, but warn, about top level language custom params 7ce033a @bep #10947
- Handle transient errors in config loading etc. 0554213 @bep #10947
- Re-establish all the server flags 5251f01 @bep #10947
- Revert "Make GOMAXPROCS CPU limit aware" 0106cf1 @bep
- Make GOMAXPROCS CPU limit aware 59050f9 @BenTheElder #10950
- Add Sections to Site interface faa6998 @bep #10947
- helpers: simplify path tests with T.TempDir 3d90871 @alexandear
- tpl: Add math.Abs bda082c @alexandear #10941
- Create a struct with all of Hugo's config options 241b21b @bep #10896 #10620
- Improve date parsing performance for the common case 6aededf @bep #10942
- Add a counter helper 0988b76 @bep
- Expand the baseline benchmark a little e0e19a9 @bep
- Revert "Update syntax-highlighting.md (#10929)" (#10930) bcd7ac7 @jmooring
- Update syntax-highlighting.md (#10929) a4fb8dc @kirillbobyrev
- tpl/strings: Clarify findRESubmatch description 5c7b79c @jmooring
- langs/i18n: Fallback to defaultContentLanguage instead of English 0cb6ca5 @jmooring #9216
- tpl/debug: Add VisualizeSpaces f106251 @bep
- Prevent the global error collector to panic when sending on closed channel 9906c1a @bep
- markup/goldmark: Add config options for the typographer extension 5596dc2 @bep #9772
- Add test for ToC vs include 5748133 @bep #10866
- resources.functions: improve validation 05c095a @deining
- markup/goldmark: Fail on invalid Markdown attributes b0b1b76 @bep
- tpl/math: Return error if less than 2 input numbers f5eddf8 @septs #10827
Dependency Updates
- Revert "build(deps): bump gocloud.dev from 0.24.0 to 0.29.0" f014921 @bep #10993
- build(deps): bump github.com/tdewolff/parse/v2 from 2.6.5 to 2.6.6 1292d5a @dependabot[bot]
- build(deps): bump gocloud.dev from 0.24.0 to 0.29.0 baa5569 @dependabot[bot]
- build(deps): bump github.com/gobuffalo/flect from 0.3.0 to 1.0.2 a5413c1 @dependabot[bot]
- build(deps): bump golang.org/x/image from 0.5.0 to 0.7.0 9cea58a @dependabot[bot]
- build(deps): bump github.com/tdewolff/minify/v2 from 2.12.4 to 2.12.5 1a5dce4 @dependabot[bot]
- build(deps): bump github.com/dustin/go-humanize from 1.0.0 to 1.0.1 065ae00 @dependabot[bot]
- build(deps): bump google.golang.org/api from 0.76.0 to 0.123.0 1a7d57c @dependabot[bot]
- build(deps): bump golang.org/x/tools from 0.4.0 to 0.9.1 bba54e6 @dependabot[bot]
- build(deps): bump github.com/cli/safeexec from 1.0.0 to 1.0.1 7370543 @dependabot[bot]
- build(deps): bump github.com/getkin/kin-openapi from 0.110.0 to 0.117.0 f6269ee @dependabot[bot]
- deps: Update github.com/evanw/esbuild v0.17.0 => v0.17.19 715d484 @bep
- deps: Update github.com/alecthomas/chroma/v2 v2.7.0 c371171 @bep
- deps: Update github.com/bep/golibsass v1.1.0 => v1.1.1 24e7d0c @bep #10629 #10491
Documentation
- docs: Regen docshelper b6e6438 @bep
- commands: Add missing gen docshelper command 943ff7f @bep #10953
- docs: Regen CLI docs 10d0fcc @bep
- tpl/lang: document delimiter option for FormatNumberCustom 1155bbc @jmooring
- Update README.md 4f341fa @bep
- Update README.md 46a3cf6 @bep
- Update README.md f1e8f01 @bep