hugo/docs/content/en/news/0.55.0-relnotes/index.md

20 KiB
Raw Blame History


date: 2019-04-08 title: "Hugo 0.55.0: The early Easter Egg Edition!" description: "Faster, virtualized Output Formats, revised shortcodes, new return keyword, and much more …" categories: ["Releases"]

Hugo 0.55 is the early Easter Egg Edition with lots of great improvements and fixes. The original motivation for this release was to prepare for Issue #5074, but the structural changes needed for that paved the way for lots of others. Please study the list of changes below, and especially the Notes section, but some headlines include:

Virtualized Output Formats

Custom Output Formats has been a really useful feature, but it has had some annoying and not so obvious restrictions that are now lifted. Now all Page collections are aware of the output format being rendered. This means, to give some examples, that:

  • In a RSS template, listing pages with their content will use output format specific shortcode templates even if the pages themselves are not configured to output to that output format.
  • Using .Render when looping over a Page collection will now work as expected.
  • Every Output Format can be paginated.

We have now also added a new Permalinkable configuration attribute, which is enabled by default for HTML and AMP.

Shortcodes Revised

Shortcodes using the {{%/* */%}} as the outer-most delimiter will now be fully rendered when sent to the content renderer (e.g. Blackfriday for Markdown), meaning they can be part of the generated table of contents, footnotes, etc.

If you want the old behavior, you can put the following line in the start of your shortcode template:

{{ $_hugo_config := `{ "version": 1 }` }}

But using the {{</* */>}} delimiter will, in most cases, be a better alternative, possibly in combination with the markdownify template func.

See #5763.

New Return Keyword for Partials

Hugo's partial and partialCached are great for template macros. With the new return keyword you can write partials as proper functions that can return any type:

{{ $v := add . 42 }}
{{ return $v }}

See #5783.

.Page on Taxonomy nodes

The taxonomy nodes now have a .Page accessor which makes it much simpler to get a proper .Title etc. This means that older and clumsy constructs can be simplified. Some examples:

<ul>
    {{ range .Data.Terms.Alphabetical }}
            <li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li>
    {{ end }}
</ul>
<ul>
    {{ range .Site.Taxonomies.tags }}
            <li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li>
    {{ end }}
</ul>

See #5719.

And it's Faster!

This version is also the fastest to date. A site building benchmark shows more than 10% decrease in both build time and memory consumption, but that depends on the site. Its quite a challenge to consistently add significant new functionality and simultaneously improve performance. Also, note that we are now more honest about build times reported (Total in 1234 ms). We now do all initialization in the Build step, so you may get a higher time reported if you, as an example, have --enableGitInfo enabled, which now is included in the reported time.

Benchmark

Thanks!

This release represents 59 contributions by 10 contributors to the main Hugo code base. @bep leads the Hugo development with a significant amount of contributions, but also a big shoutout to @mcdee, @quasilyte, and @danielcompton for their ongoing contributions. And a big thanks to @digitalcraftsman and @onedrawingperday for their relentless work on keeping the themes site in pristine condition and to @kaushalmodi for his great work on the documentation site.

Many have also been busy writing and fixing the documentation in hugoDocs, which has received 36 contributions by 21 contributors. A special thanks to @bep, @peaceiris, @budparr, and @tinymachine for their work on the documentation site.

As this release has required a significant effort with manual testing, a special thanks go to @onedrawingperday (the 300 theme demo sites have been invaluable to check for API-breakage!), @adiabatic, and @divinerites.

Hugo now has:

Notes

  • {{ % as the outer-most shortcode delimiter means "pass the inner content to the content renderer" (e.g. Blackfriday); the old behavior can be had, see #5763
  • preserveTaxonomyNamesconfiguration option is removed. Use .Page.Title.
  • We no longer limit the number of pages passed to the RSS Output Format. We have moved that limit to the internal RSS template, and you can do so yourself using the Config.Services.RSS.Limit in your custom template.
  • We no longer add XML headers to Output Formats that output XML (<?xml version="1.0" encoding="utf-8" standalone="yes" ?>). This header is moved to the templates. If you have custom RSS or sitemap templates you may want to add the XML declaration to these. Since they, by default, is handled by Go's HTML template package, you must do something like this to make sure it's preserved: {{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
  • More honest build times reported (Total in 1234 ms). We now do all initialization in the Build step, so you may get a higher time reported if you, as an example, have --enableGitInfo enabled, which now is included in the reported time.
  • The taxonomy nodes now have a .Page accessor which makes it much simpler to get a proper .Title etc. see #5719.
  • The template keywords with and if now work properly for zero and interface types, see #5739
  • Taxonomy terms lists (Page of Kind taxonomyTerm) without any date(s) set (e.g. from front matter) will now pick the latest dates from the child pages. This is in line with how other branch nodes work in Hugo.
  • A new configuration option, Permalinkable, is added to Output Format and enabled that by default for HTML and AMP types. See #5706
  • --stepAnalysis is removed. If you want to really understand the latency in your project in Hugo, try the new --trace flag and pass that file to the many tools that read Go Trace files. There are also some newly hidden flags in --profile-cpu, --profile-men, --profile-mutex, hidden because they are considered to be only of interest to developers.
  • Chroma is updated with many fixes and new lexers, see #5797
  • We now support Page-relative aliases, e.g. aliases that do not start with a /, see #5757
  • We now support context-relative (language) URLs in front matter, meaning that in most cases url: /en/mypage can be replaced with the more portable url: mypage. See #5704

Enhancements

Templates

Output

Core

Other

Fixes

Templates

Core

Other