Repository navigation
v0.166.0
This release is mostly about hardening and bug fixes, but there are some notable changes:
.Rendernow takes an optional context argument:{{ .Render "view" $ctx }}, mirroring thepartialAPI. This makes it possible to pass e.g. a dict to a content view. See #15077.- The
returnkeyword in templates has been reimplemented. It now works in any template (not just partials) and can be used anywhere, e.g. insideiforrangeblocks. See #15212. - New
resources.Publishtemplate function andIndexOfmethod onPages. relatedconfig: newtokenizeoption for index values, and index creation is faster.- Several security fixes; see the notes below.
Note
- tpl/transform: Bump fileCacheEntryVersion in transform.ToMath (note) 8d88b8b @bep #15267
- resources/images: Bump formatVersionNumbers.PNG and fix version cache busting for images.Filter (note) d19e0a4 @bep #12536 #12543 #15266
- warpc/js: Upgrade katex to 0.18.4 (note) ec52e63 @bep #15254
- hexec: Fail on symlinks that escape the Node.js permission paths c05c012 @bep
- config/security: Deny text/org content by default e6abb9c @bep
- config/security: Add http.proxyFromEnvironment and document the resolved address check 6a2a955 @bep #15301 #15302
- deps: Upgrade github.com/gobwas/glob v0.2.3 => v1.0.0 efd2456 @bep #15273
- hugofs: Drop symlinked mount roots 938c820 @bep
- tpl: Improve the return keyword in templates 8405b80 @bep #15212
- resources/page: Don't let a title's "/" split an auto-derived slug 39507d5 @ipince #4092 #3577 #5571 #4090
Glob patterns
The glob library used for e.g. module mounts (includeFiles, excludeFiles), cascade targets, segments, deployment matchers and noVendor has been upgraded to v1.0.0. This is a complete rewrite of the matching engine that fixes a long list of correctness bugs, but it also means that some patterns may behave differently:
- Malformed patterns (e.g. an unclosed
{, an empty[]class) now fail with a syntax error instead of being silently accepted. **matches any sequence of characters including separators, but it is not the**/"globstar" of shells:**/xrequires the literal/and does not matchx, anda/**/bdoes not matcha/b. Use{**/,}xif you need both.\is the escape character, so a literal backslash must be written as\\.
If a pattern that used to match no longer does (or vice versa), it was most likely relying on a bug in the old engine.
Security
text/orgcontent is now denied by default, as Org mode's export blocks and@@html:...@@snippets pass raw HTML through unescaped, making it the same XSS sink astext/html. Sites with Org content can opt back in viasecurity.allowContent.- Remote fetches (
resources.GetRemoteetc.) now validate the resolved address at dial time and reject loopback, private, link-local, CGNAT and similar ranges. This only applies under the defaultsecurity.http.urlsallowlist; if you have customized it, you have opted into your own hosts and the check stands down. Proxies fromHTTP_PROXY/HTTPS_PROXYhide the destination address from this check and are now ignored unless you setsecurity.http.proxyFromEnvironment = true. - Node.js tools (PostCSS, Tailwind CSS etc.) now fail before invocation if a symlink inside the project resolves outside the allowed read/write roots. If you have a legitimate link, add its target to
security.node.permissions.allowRead. - Mount roots that are themselves symlinks (e.g.
themes/mytheme/assets -> /somewhere/else) are now dropped. This closes a gap in thethemes/confinement; absolute mountsourcevalues are still allowed.
Other
{{ return <value> }}outside a partial is now an error; it was previously silently ignored.- A page without an explicit
slugwhose title contains a/(e.g.Watch/listen to this) now gets a single URL segment (.../watch-listen-to-this/) instead of a nested one (.../watch/listen-to-this/). Taxonomy and term pages are not affected. - Hugo is now built with Go 1.27.
KaTeX
When upgrading to Hugo v0.166.0, sites using transform.ToMath with the output option set to html or htmlAndMathml must update the KaTeX stylesheet referenced in their template(s) to version 0.18.4 or higher. Using older CSS versions like 0.16.21 will cause certain mathematical or chemical expressions to render incorrectly.
Example update:
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css">
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.18.4/dist/katex.min.css">See these examples:
- https://gohugo.io/functions/transform/tomath/#step-3
- https://gohugo.io/render-hooks/passthrough/#example
Bug fixes
- tpl/strings: Fix replaceRE with zero-width assertions ae07063 @youdie006
- common/hreflect: Fix the off-by-one in the float to int overflow guards 5130d00 @youdie006
- resources/images: Fix filters on transparent colors and paletted images 7785668 @bep #12536 #12543
- github: Fix workflow for stale issues efe5cbc @jmooring #15261
- all: Run modernize -fix ./... 7b5199f @bep
- commands: Fix lang flag description in config command 87260e4 @jmooring #15223
- hugolib: Fix slice bounds panic when deleting multiple nodes at same path 49dceb1 @bep #15207
- hugolib: Fix ReadingTime and FuzzyWordCount calculations 5e70992 @jmooring #15206
Improvements
- js: Add es2025 as supported build target 857120b @bep #15307
- hugofs: Drop symlinked mount roots 938c820 @bep
- markup/highlight: Escape lineAnchors before passing it to Chroma 3b2d3b8 @bep
- tpl/partials: Slight performance improvement of the common partialCached case 9c2527f @bep
- Add internalExternal.IgnoreTailwindCSSSecurityError config option a36bd27 @bep
- config/security: Harden the default http.urls and resolved address checks (#15285) 24d5e42 @bep
- resources/images: Preserve the source palette for geometric filter chains 9e7c978 @bep #12543
- resources/images: Add golden test cases for geometric filter chains on paletted images 6b5b7d8 @bep #12543
- resources/images: Add some golden test cases 62e24b7 @bep #12536 #12543
- related: Speed up index creation f61346e @bep
- related: Add tokenize option for index values 850f11c @jmooring #7515 #15199
- resources/page: Don't let a title's "/" split an auto-derived slug 39507d5 @ipince #4092 #3577 #5571 #4090
- config/allconfig: Improve resilience of hugo mod init 90fe506 @jmooring #15253
- tpl: Separate deferred templates by escaping mode 49835f8 @Soundcreates #15234
- resources: Validate the resolved address on remote fetches d6e6f9e @bep #15247
- markup: Escape code-fence attribute values in the default renderer e4dc48c @bep #15247
- hugolib: Make .Render take an optional context argument bcde806 @bep #15077
- modules/npm: Make the generated workspace package private with a stable name df4ac34 @bep #15245
- common/hstore: Keep read lock while sorting map values 166d3ee @Soundcreates #15237
- metrics: Improve template metrics duration formatting a25af7f @Shiwang0-0 #15027
- Remove comments from rebuild test functions 723579f @bep
- hugolib: Add some fast render mode integration tests 85ad5e4 @bep
- Upgrade to Go 1.27 e31ff54 @bep #15228
- tpl: Improve the return keyword in templates 8405b80 @bep #15212
- page: Add IndexOf method to Pages bf05832 @Shiwang0-0 #13589
- tpl/resources: Add resources.Publish a05736c @bep #15208
- markup/pandoc: Support pandoc 3.11 and later 423e9ce @jmooring #15271 #15280
Dependency Updates
- build(deps): bump google.golang.org/grpc from 1.83.1 to 1.83.2 3fbfd27 @dependabot[bot]
- build(deps): bump golang.org/x/sync from 0.22.0 to 0.23.0 393de58 @dependabot[bot]
- build(deps): bump golang.org/x/mod from 0.40.0 to 0.41.0 870f746 @dependabot[bot]
- build(deps): bump github.com/getkin/kin-openapi from 0.146.0 to 0.149.0 6152e22 @dependabot[bot]
- build(deps): bump github.com/bits-and-blooms/bitset 5b6e7c2 @dependabot[bot]
- build(deps): bump github.com/bep/lazycache from 0.8.1 to 0.9.0 dc03bb2 @dependabot[bot]
- build(deps): bump github.com/bep/tmc from 0.6.0 to 0.7.0 701dd33 @dependabot[bot]
- build(deps): bump github.com/yuin/goldmark from 1.8.5 to 1.8.6 b4062c8 @dependabot[bot]
- build(deps): bump golang.org/x/image from 0.44.0 to 0.45.0 cdd1627 @dependabot[bot]
- deps: Upgrade github.com/gobwas/glob v0.2.3 => v1.0.0 efd2456 @bep #15273
- build(deps): bump golang.org/x/mod from 0.39.0 to 0.40.0 d462968 @dependabot[bot]
- build(deps): bump github.com/tdewolff/minify/v2 from 2.24.16 to 2.24.17 fd5f7c6 @dependabot[bot]
- build(deps): bump github.com/gohugoio/httpcache from 0.8.0 to 0.9.0 6b33517 @dependabot[bot]
- build(deps): bump google.golang.org/grpc from 1.82.1 to 1.83.1 5f0d88b @dependabot[bot]
- build(deps): bump golang.org/x/tools from 0.48.0 to 0.49.0 9171dae @dependabot[bot]
- build(deps): bump software.sslmate.com/src/go-pkcs12 from 0.7.0 to 0.7.2 d1ee825 @dependabot[bot]