github gohugoio/hugo v0.108.0

latest releases: v0.126.1, v0.126.0, v0.125.7...
17 months ago

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

Don't miss a new hugo release

NewReleases is sending notifications on new releases.