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 incascade
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 arelayout
,type
,outputs
,weight
) using thecascade
keyword, e.g. “I want this subsection to be rendered in both theHTML
andCalendar
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
andresources.GetMatch
. These behaves like their namesake methods onPage
(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…