github gohugoio/hugo v0.111.0

latest releases: v0.137.0, v0.136.5, v0.136.4...
20 months ago

Hugo 0.111.0 is the second Hugo release of the year. Note: There's already a patch release.

Notable news

Page Fragments

We added the new .Fragments method on Page as part of the Related Content feature refresh (below), but it's plenty useful on its own, and has been long sought after by Hugo users.

It has many uses: Build table of contents, check if a page fragment (heading identifier) exists on a page, check for duplicate heading identifiers, start table of contents from a specific heading identifier. See the Hugo Documentation for more information

Indexing of Page Fragments in Related Content

We have reworked the Related Content API so it's now one method .Related that takes either a Page or an options map. We have also introduced a new type attribute on the index configuration with the new type fragments. See this for details, but to add some weight to the page titles in the Related Content configuration you can do this:

[related]
threshold    = 20
includeNewer = true
toLower      = false
[[related.indices]]
name        = "fragmentrefs"
type        = "fragments"
applyFilter = false
weight = 50

See the Hugo Documentation for more.

Global page func

Note: There was a bug in this release that made this new feature not working, so you need to upgrade to Hugo 0.111.1. We blame it on Go.

Hugo almost always passes a Page as the data context into the top level template (e.g. single.html) (the one exception is the multihost sitemap template). This means that you can access the current page with the . variable in the template.

But when you're deeply nested inside .Render, partial etc., accessing that Page object isn't always practical or possible.

For this reason, Hugo now provides a global page function that you can use to access the current page from anywhere in any template.

{{ page.Title }}

Notes

  • For the Goldmark markdown hander, we now split parse and render for Goldmark. This was motivated by the new fragments support in Related Content, but it has some other side effects: If you only need a page's table of contents, we now skip the rendering step, which makes it faster, but it also means that you can access the page .Fragments structure from everywhere, even in render hooks (271318a @bep #10750)
  • tpl/tplimpl: Remove the Google News internal template 66f94b4 @jmooring
  • Only invoke a given cached partial once 4ef9baf @bep #4086 #9588

Bug fixes

Improvements

Dependency Updates

Documentation

Build Setup

Don't miss a new hugo release

NewReleases is sending notifications on new releases.