Even faster, continue and break support, short-circuit of the built-in and/or-operators. This release upgrades to Go 1.18. This has made Hugo even faster. How much faster will depend on your site etc., but GoHugo team have benchmarks that show significant improvements. But the main reason GoHugo team and me are exited about this is the improvements in Go templates:
There are two new keywords, break
and continue
. These behaves like you would expect coming from other programming languages:
{{ range $i, $p := site.RegularPages }}
{{ if gt $i 2 }}
{{/* Break out of range, we only want to print the first 3 pages. */}}
{{ break }}
{{ end }}
{{ $p.Title }}
{{ end }}
{{ range $i, $p := site.RegularPages }}
{{ if eq $i 2 }}
{{/* Skip the 3rd page. */}}
{{ continue }}
{{ end }}
{{ $p.Title }}
{{ end }}
Also, the two built-in operators/function and
and or
now short-circuits, also in line with how &&
and ||
behave in other programming languages. This is useful in situations where the right side may have side effects (may be nil
, is slow to execute etc.):
{{ if and .File (eq .File.Extension "html") }}
{{ end }}
Notes
- Hugo now only builds with Go versions >= 1.18. Note that you do not need Go installed to run Hugo, and for Hugo Modules, any recent Go version can be used.
Changes
- readme: Add note about Go 1.18
5930173
@bep - tpl: Pull in Go 1.18 patch that fixes the “no space in {{ continue }} and {{ break }}” bug
3476b53
@bep - readme: Add a contribution note
e792d27
@bep - github: Make it build with Go 1.18
9d6495d
@bep - tpl: Adjustments and an integration test for Go 1.18
42cc5f8
@bep #9677 - Remove Go 1.17 support
a6488e7
@bep #9677 - tpl: Sync go_templates for Go 1.18
65a78ca
@bep #9677 - build: Bump to Go 1.18
4d6d1d0
@bep #9677 - dartsass: Improve error message when no read access
b60e1bb
@bep #9662 - Fix and refactor typos
61cf3c9
@CathrinePaulsen - Improve server startup/shutdown
31fbc08
@bep #9671 - commands: Improve server tests
cebd886
@bep #9647