github gohugoio/hugo v0.109.0

latest releases: v0.128.1, v0.128.0, v0.127.0...
18 months ago

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

Improvements

Dependency Updates

Documentation

Build Setup

Footnotes

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

Don't miss a new hugo release

NewReleases is sending notifications on new releases.