Hugo 0.57: The Cascading Edition

https://gohugo.io/news/0.57.0-relnotes/

Featured Image for Hugo 0.57: The Cascading Edition

Hugo 0.57 brings Cascading Front Matter , Alphabetical Sorting , Resources Loading from Assets with Wildcards . And more.

Cascading Front Matter : We have added a new and powerful cascade keyword to Hugo’s front matter. This can be added to any index node in _index.md . Any values in cascade will be merged into itself and all the descendants.

title: "My Blog"
icon: "world.png"
cascade:
   icon: "flag.png"
   outputs: ["HTML"]
   type: "blog"

It’s worth noting that the cascade element itself will also be merged. Also, to grasp the full value of this feature, remember that front matter in Hugo is both data and behaviour : You can tell Hugo how to process a subset of the pages (some example keywords are layout , type , outputs , weight ) using the cascade keyword, e.g. “I want this subsection to be rendered in both the HTML and Calendar Output Formats” .

This feature is created by@regisphilibert and @bep See #6041 for details.

Resources Loading from Assets with Wildcards : We have added two new sought after template functions to the resources namespace: resources.Match and resources.GetMatch . These behaves like their namesake methods on Page (with super-asterisk wildcard support), but searches in all the resources in Assets. E.g. {{ $prettyImages := resources.Match "images/**pretty.jpg" }} will give a slice of all “pretty pictures”. Another relevant example: {{ $js := resources.Match "libs/*.js" | resources.Concat "js/bundle.js" }} .

Performance: In general, this version is slightly faster and more memory effective. In particular, we have fixed a performance issue with the replacer step that greatly improves the build speed of certain large and content-rich sites (thanks to @vazrupe for the fix).

Notes

  • All string sorting in Hugo is now alphabetical/lexicographical.
  • home.Pages now only returns pages in the top level section. Before this release, it included all regular pages in the site . This made it easy to list all the pages on home page, but it also meant that you needed to take special care if you wanted to navigate the page tree from top to bottom. If you need all regular pages , use .Site.RegularPages . Also see #6153.
  • .Pages now include sections. We have added .RegularPages as a convenience method if you want the old behaviour. See #6154 for details.
  • Hugo now only “auto create” sections for the home page and the top level folders. The other sections need a _index.md file. See #6171 for details.

Sometimes I feel like my sites are overly simple, as I often have no need for new Hugo features. The cascade for front matter is pretty interesting though…

https://gohugo.io/news/0.57.1-relnotes/

This is a bug-fix release with a couple of important fixes.

https://gohugo.io/news/0.57.2-relnotes/

Hugo 0.57.0 had some well-intended breaking changes. And while they made a lot of sense, one of them made a little too much noise.

This release reverts the behavior for .Pages on the home page to how it behaved in 0.56, but adds a WARNING telling you what to do to prepare for Hugo 0.58.

In short, .Page home will from 0.58 only return its immediate children (sections and regular pages).

In this release it returns .Site.RegularPages . So to prepare for Hugo 0.58 you can either use .Site.RegularPages in your home template, or if you have a general list.html or RSS template, you can do something like this:

{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := $pctx.RegularPages -}}