Skip to content

v0.95.0

Compare
Choose a tag to compare
@bep bep released this 16 Mar 15:38
· 1399 commits to master since this release

Even faster, continue and break support, short-circuit of the built-in and/or-operators. This release upgrades to Go 1.18 which was released yesterday. This has made Hugo even faster. How much faster will depend on your site etc., but we have benchmarks that show significant improvements. But the main reason we're 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 }}

Hugo now has:

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