Skip to content

Releases: gohugoio/hugo

v0.111.3

12 Mar 12:00
@bep bep
Compare
Choose a tag to compare

Bug fixes

  • Fix "unknown shortcode token" when calling shortcode within fenced code block e7148f3 @bep #10819
  • Don't fail when calling Paginate with an empty pages.PagesGroup 34a86e1 @bep #10802
  • Improve error message for unclosed shortcode with inner content 9818724 @deining

Improvements

Dependency Updates

Documentation

v0.111.2

05 Mar 12:43
@bep bep
Compare
Choose a tag to compare

Bug fixes

Documentation

Build Setup

v0.111.1

02 Mar 10:30
@bep bep
Compare
Choose a tag to compare

This fixes the "page" not defined issue in Hugo 0.111.0. eef23a7 @bep #10774

v0.111.0

01 Mar 21:13
@bep bep
Compare
Choose a tag to compare

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

v0.110.0

17 Jan 12:33
@bep bep
Compare
Choose a tag to compare

Note

Bug fixes

Improvements

Dependency Updates

Documentation

Build Setup

v0.109.0

23 Dec 10:53
@bep bep
Compare
Choose a tag to compare

Hugo v0.109.0 is the last release of 2022 – and with that we're wishing all of you a very merry Christmas and a prosperous new year1.

Notable new features

Pass variables to SCSS/SASS

Hugo has had great SCSS/SASS support, but passing variables (e.g. theme colours from config) down to the transpiler has been much harder than it should.

In Hugo v0.109.0 we added a new vars option and you can finally just do:

{{ $vars := dict "color1" "blue" "color2" "green" "font_size" "24px" }}
{{ $opts := (dict "transpiler" "dartsass" "outputStyle" "compressed" "vars" $vars ) }}
{{ $r := resources.Get "scss/main.scss" | toCSS $opts }}

And then in the SCSS file:

@use "hugo:vars" as v;

p {
    color: v.$color1;
    font-size: v.$font-size;
}

More examples here.

Hugo Module Workspaces

Workspace support was added in Go 1.18, and in this release Hugo finally gets solid support for it.

A common use case for a workspace is to simplify local development of a site with its theme modules.

A workspace can be configured in a *.work file and activated with the module.workspace setting, which for this use is commonly controlled via the HUGO_MODULE_WORKSPACE OS environment variable.

See the hugo.work file in the Hugo Docs repo for an example:

go 1.19

use .
use ../gohugoioTheme

Using the use directive, list all the modules you want to work on, pointing to its relative location. As in the example above, it's recommended to always include the main project (the ".") in the list.

With that you can start the Hugo server with that workspace enabled:

HUGO_MODULE_WORKSPACE=hugo.work hugo server --ignoreVendorPaths "**"

The --ignoreVendorPaths flag is added above to ignore any of the vendored dependencies inside _vendor. If you don't use vendoring, you don't need that flag. But now the server is set up watching the files and directories in the workspace and you can see your local edits reloaded.

Breadcrumbs

We have added a new .Ancestors method on Page that walks up the tree to the home page. With this, breadcrumbs templates can be greatly simplified:

<ol>
  <ul>
    {{- range .Ancestors.Reverse }}
      <li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
    {{- end }}
    <li class="active" aria-current="page">
      <a href="{{ .Permalink }}">{{ .Title }}</a>
    </li>
  </ul>
</ol>

The path to /public now available in PostCSS

So you can do process.env.HUGO_PUBLISHDIR in your postcss.config.js to figure out where Hugo publishes
its files.

Note that the value will always be an absolute file path and will point to a directory on disk even when running hugo server in memory mode.

If you write to this folder from PostCSS when running the server, you could run the server with one of these flags:

hugo server --renderToDisk
hugo server --renderStaticToDisk

Note

Bug fixes

  • If you use the legacy libsass transpiler in toCSS and uses the cached build to avoid having the extended version installed on the CI server, you need to rebuild those assets and commit them to source control (e.g. with hugo --gc).
  • tpl/resources: Fix data race in ToCSS aa2c724 @bep #10542
  • tocss: Fix unquote case with double quotes 5d5f0a2 @septs #10555
  • resources/js: Fix some import discrepancies between Hugo and ESBuild b54de1b @bep #10527
  • parser/metadecoders: Fix spelling e0e63f3 @lacamera

Improvements

Dependency Updates

Documentation

Build Setup

  1. We're working on some bigger and even more exiting Hugo features that will be ready early next year. Stay tuned!

v0.108.0

06 Dec 13:58
@bep bep
Compare
Choose a tag to compare

With Hugo v0.108.0 you can render standalone Markdown images without a surrounding paragraph. Both the HTML- and CommonMark-specification defines image as an inline element. For Markdown, this has meant that if you put an image on its own (not inlined in another paragraph), it would be wrapped in <p></p> tags, even if you provide your own Render Hook Template.

Now you can get by this annoyance by setting markup.goldmark.parser.wrapStandAloneImageWithinParagraph = false

[markup]
  [markup.goldmark]
    [markup.goldmark.parser]
      wrapStandAloneImageWithinParagraph = false
      [markup.goldmark.parser.attribute]
        block = true

In the above we have also enabled attribute support for Markdown blocks to illustrate another nice side effect of this; it's now possible to use Markdown attributes (e.g. CSS classes) on standalone images:

This is an inline image: ![Inline Image](/inline.jpg). Some more text.

![Block Image](/block.jpg)
{.blue}

The images in the above Markdown example would, given the hook template below, be rendered wrapped in a figure element with the blue CSS class applied in the latter example.

{{ if .IsBlock }}<figure class="{{ .Attributes.class }}"><img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" /></figure>
{{ else }}<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />{{ end }}

Two new fields are added to the render context passed to image render hooks:

Bug fixes

  • common/hugio: Fix multiWriteCloser.Close 5067775 @bep #10505
  • tpl/collections: Fix some index cases where the indices given is a slice and be more lenient with nil inputs d373774 @bep #10489

Improvements

Dependency Updates

  • deps: Upgrade github.com/bep/godartsass v0.15.0 => v0.16.0 f5b5b71 @bep
  • build(deps): bump github.com/getkin/kin-openapi from 0.109.0 to 0.110.0 50549c8 @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.15.16 to 0.15.18 535ea8c @dependabot[bot]
  • build(deps): bump golang.org/x/text from 0.4.0 to 0.5.0 8bbec42 @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.15.15 to 0.15.16 0bfa293 @dependabot[bot]
  • deps: Upgrade github.com/bep/godartsass v0.14.0 => v0.15.0 83080df @bep

Documentation

v0.107.0

24 Nov 14:15
@bep bep
Compare
Choose a tag to compare

This release is mostly interesting if you do code highlighting. We fixed a bottle neck which should show a significant performance boost for sites using code highlighting. Hugo's gohugo.io docs site builds ~20% faster. Also, Chroma, the highlighting library, is upgraded to v2.4.0 with new lexers and lots of improvements.

Bug fixes

Improvements

Dependency Updates

  • build(deps): bump github.com/getkin/kin-openapi from 0.108.0 to 0.109.0 6a004b8 @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.15.14 to 0.15.15 0923622 @dependabot[bot]
  • build(deps): bump github.com/frankban/quicktest from 1.14.3 to 1.14.4 7477672 @dependabot[bot]
  • build(deps): bump golang.org/x/tools from 0.2.0 to 0.3.0 63f7f0f @dependabot[bot]
  • deps: Upgrade github.com/alecthomas/chroma/v2 v2.4.0 bcb62d8 @bep

v0.106.0

17 Nov 18:52
@bep bep
Compare
Choose a tag to compare

Bug fixes

Dependency Updates

  • build(deps): bump github.com/pelletier/go-toml/v2 from 2.0.4 to 2.0.6 bafb389 @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.15.13 to 0.15.14 cdd83bf @dependabot[bot]
  • deps: Update the libweb version string e00220a @bep
  • deps: Upgrade github.com/bep/gowebp v0.1.0 => v0.2.0 a662dda @bep
  • build(deps): bump github.com/yuin/goldmark from 1.5.2 to 1.5.3 fe08d35 @dependabot[bot]
  • build(deps): bump github.com/spf13/afero from 1.9.2 to 1.9.3 4b675dd @dependabot[bot]
  • build(deps): bump github.com/getkin/kin-openapi from 0.107.0 to 0.108.0 24eaa29 @dependabot[bot]
  • build(deps): bump github.com/clbanning/mxj/v2 from 2.5.6 to 2.5.7 58a98c7 @dependabot[bot]
  • build(deps): bump golang.org/x/net from 0.1.0 to 0.2.0 900904f @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.15.12 to 0.15.13 24eca0c @dependabot[bot]

Documentation

v0.105.0

28 Oct 12:51
@bep bep
Compare
Choose a tag to compare

Bug fixes

Improvements

Dependency Updates

  • build(deps): bump golang.org/x/tools from 0.1.12 to 0.2.0 f505854 @dependabot[bot]
  • build(deps): bump github.com/getkin/kin-openapi from 0.106.0 to 0.107.0 2aedccc @dependabot[bot]
  • build(deps): bump golang.org/x/text from 0.3.7 to 0.4.0 c109314 @dependabot[bot]
  • build(deps): bump github.com/spf13/cobra from 1.5.0 to 1.6.1 4732c47 @dependabot[bot]
  • build(deps): bump github.com/getkin/kin-openapi from 0.103.0 to 0.106.0 62780ec @dependabot[bot]
  • build(deps): bump github.com/tdewolff/minify/v2 from 2.12.1 to 2.12.4 351d6b0 @dependabot[bot]
  • build(deps): bump github.com/yuin/goldmark from 1.4.15 to 1.5.2 ed930db @dependabot[bot]
  • build(deps): bump github.com/fsnotify/fsnotify from 1.5.4 to 1.6.0 05df964 @dependabot[bot]
  • build(deps): bump github.com/magefile/mage from 1.13.0 to 1.14.0 9860e0e @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.15.9 to 0.15.12 2ef60db @dependabot[bot]

Documentation

Build Setup