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
- strings: fix Truncate behavior for formatted html c0d15a2 @khayyamsaleem #10399
- Fix shortcode error when closing without .Inner ae48507 @bep #10672
- create: Fix typo in error message 2dad13c @aaronhooper
- resource_transformers/tocss: Fixed hugo:vars casting a1a9c08 @acclassic #10632
- markup: Fix linenos codeblock hl option case regression 73ece30 @khayyamsaleem #10682
- Fix slow HTML elements collector for the pre case f9fc0e0 @bep #10698
- commands: Fix server url rewrites (http status 200) 1477d0b @bep #10668
- Fix description of collections.Uniq 4ccc8cf @jmooring
- Fix shortcode detection in RenderString 1688583 @bep #10654
Improvements
- Replace deprecated ioutil with io and os d453c12 @alexandear
- build: Bump build images 60e6fa7 @bep
- build: Update Linux ARM build image 7e51ba0 @bep
- tpl/tplimpl: Remove the Google News internal template 66f94b4 @jmooring
- tpl/strings: Adjust benchmark 2a61910 @bep
- tpl/strings: Add BenchmarkTruncate 079d1b6 @bep
- Misc ioutil deprecation adjustments a669467 @bep #10732
- Remove unused temp directory e314410 @alexandear
- exif: Return the proper exposure time value in some special cases 39cc3a2 @WaltCuller #10738
- Add a page template func ce524d0 @bep #9339
- dartsass: Import CSS without extension at compile time 2662faf @jmooring #10592
- Split parse and render for Goldmark 271318a @bep #10750
- related: Add config option cardinalityThreshold e442a63 @bep #10744
- Throw an error when shortcode is expected to be closed 7d78a49 @bep #10675
- Add some shortcode testcases 0dbeac8 @bep #10671
- sass: Remove some unused leftover code b99d073 @bep
- resources/sass: Remove debug statements e965cb6 @jmooring #10470
- page: Move the cache double check right after the lock 586fea0 @bep
- page: Add some concurrency to the building of the related page index fa2d7ad @bep #10711
- related: Adjust benchmark 4346987 @bep
- tocss: Simplify the hugo:vars type handling ecf3cd5 @bep #10632
- Adjust tests for GO 1.20 6abd15e @bep #10691
- tpl/internal: Sync Go template src to Go 1.20 094135f @bep #10691
- Add page fragments support to Related 90da766 @bep #10711 #9339 #10725
- related: Adjust benchmark 0afec0a @bep
- related: Add benchmark 28540ed @bep
- tpl/collections: Improve error message in Index 9af78d1 @bep
- Make the HTML collector parsing more robust d33a7eb @bep #10698
- tpl/strings: Add strings.ContainsNonSpace fce0890 @bep
- publisher: Add benchmark 4f4a1c0 @bep
- Update CONTRIBUTING.md e2cfc3d @bep
- Only invoke a given cached partial once 4ef9baf @bep #4086 #9588
Dependency Updates
- Revert "build(deps): bump gocloud.dev from 0.24.0 to 0.28.0 (#10610)" db9f74d @bep #10770
- build(deps): bump github.com/tdewolff/parse/v2 from 2.6.4 to 2.6.5 4d36b99 @dependabot[bot]
- build(deps): bump github.com/mattn/go-isatty from 0.0.16 to 0.0.17 807237b @dependabot[bot]
- build(deps): bump golang.org/x/image 79b03b3 @dependabot[bot]
- build(deps): bump golang.org/x/net from 0.4.0 to 0.7.0 4bf91b9 @dependabot[bot]
- Revert "build(deps): bump github.com/getkin/kin-openapi from 0.110.0 to 0.114.0" 2a364cc @bep
- deps: Upgrade github.com/yuin/goldmark v1.5.3 => v1.5.4 3fb2417 @jmooring #10661
- build(deps): bump github.com/getkin/kin-openapi from 0.110.0 to 0.114.0 87c78bd @dependabot[bot]
- deps: Upgrade github.com/alecthomas/chroma v2.4.0 => v2.5.0 69c369e @jmooring #9890 #10692
- build(deps): bump github.com/kyokomi/emoji/v2 from 2.2.10 to 2.2.11 dd37163 @dependabot[bot]
- build(deps): bump gocloud.dev from 0.24.0 to 0.28.0 (#10610) c3a59a7 @dependabot[bot] #9778
Documentation
- docs: Another fix related docs example d5601e8 @bep
- docs: Fix related docs example cedd04d @bep
- cods: Regen docs helper a56b907 @bep
- Move the Related doc counter to prevent a race 5c317c5 @bep #10768
- Update README.md 93ed6e4 @bep
Build Setup
- build: Update to Go 1.20 4801e2e @bep #10691
- snap: Install dart-sass-embedded for 32-bit ARM (armhf) too 76c6140 @anthonyfok
- snap: Add read access for ~/.gitconfig.local and ~/.config/git/* too d4482e8 @anthonyfok #10337