v0.100.0
$page.RenderString
(see #6703) finally supports shortcodes, and shortcode improvements is the main theme in Hugo 0.100.0.
Indentation fixes for shortcode blocks: We now record the indentation before the opening shortcode tag when parsing the source. This allow us to fix a couple of annoying issues in Hugo:
- We have added a new
.InnerIndent
method to the shortcode context to prevent thehighlight
shortcode from including in the indentation as part of the code block. See #4717. - Hugo now preserves the indentation for shortcode blocks. See more below.
A shortcode block is when the shortcode is included as the first non-whitespace content on a line. Note that this does not touch shortcodes with inner content, where the user is in control of the indentation. See issue #9946 for more information. An example, say that I have this in layouts/shortcodes/mylist.md
:
* Culpa enim incididunt fugiat id dolore velit laboris veniam minim.
* Tempor ex nisi labore ad elit laborum ex ullamco aute labore eu occaecat.
* Deserunt mollit aliqua est laboris et irure eu non.
* Consectetur nulla minim non reprehenderit Lorem elit dolore quis.
And then use that shortcode in a content file:
* My List
{{% mylist %}}
In earlier versions of Hugo the above would render as:
Now it renders as:
Note that in the example above we use the md
file suffix for the shortcode. In this release we also added Markdown
as a built-in output format in Hugo, defined as a plain text format, meaning you get more lenient parsing compared to HTML. Using this if your shortcode produces Markdown has fewer quirks. See #9821.
Also noteworthy is the new template function resources.Copy which allows you to copy almost any Hugo Resource
(the one exception is the Page
), possibly most useful for renaming things:
This release represents 32 contributions by 4 contributors to the main Hugo code base.@bep leads the Hugo development with a significant amount of contributions, but also a big shoutout to @dependabot[bot], @satotake, and @moorereason for their ongoing contributions.
Many have also been busy writing and fixing the documentation in hugoDocs,
which has received 1 contributions by 1 contributors.
Hugo now has:
- 59255+ stars
- 428+ contributors
- 399+ themes
Notes
- The methods on Page
IsDescendant
andIsAncestor
now return false for itself, which is obviously the correct behaviour. We have fixed this before, but reverted it because it broke some theme's logic. Looking back, that reversion was a mistake. If you want the old logic you can get that by doing something ala{{ if or (eq $p1 $p2) ($p1.IsAncestor $p2) }}{{ end }}
#9925 - We have removed Blackfriday as a Markdown option. It has been deprecated for a long time, its v1 version is not maintained anymore, and there are many known issues. Goldmark should be a mature replacement by now. #9944
Changes
- docs: Regen CLI docs 3fcbee2 @bep
- docs: Regen docs helper db9d274 @bep
- Fix indentation in highlight shortcode 6f7bf3f @bep #4717
- Make .RenderString render shortcodes 9e904d7 @bep #6703
- Improve shortcode indentation handling d2cfaed @bep #9946
- Add Markdown as an output format 322d19a @bep #9821
- build(deps): bump github.com/evanw/esbuild from 0.14.39 to 0.14.42 7cb484e @dependabot[bot]
- Run go mod tidy 0b395f0 @bep
- Add a shortcode benchmark c1a8307 @bep
- Remove Blackfriday markdown engine 0f8dc47 @bep #9934
- Fix HasMenuCurrent and IsDescendant/IsAncestor when comparing to itself 3b478f5 @bep #9846
- build(deps): bump github.com/sanity-io/litter from 1.5.4 to 1.5.5 f343b8e @dependabot[bot]
- deps: Update to github.com/tdewolff/minify/v2 v2.11.5 60ede14 @bep
- Don't use the baseURL /path as part of the resource cache key dd9eaf1 @bep #9787
- postcss: Make the resource cache key more stable 46a2ea6 @bep #9787
- commands: Fix case where languages cannot be configured 653ab2c @bep
- github: Set HUGO_BUILD_TAGS: extended when running tests 52edea0 @bep #9935
- metrics: Fix divide by zero error 6a5acd7 @moorereason
- Fix error message when PostCSS config file is not found 805b215 @bep #9927
- server: Skip watching dirs in ignoreFiles 8ca7052 @bep #9838
- resources: Improve error message on .Resize etc. on SVGs bb232a3 @bep #9875
- Fix Plainify edge cases 3854a6f @bep #9199 #9909 #9410
- Add resources.Copy cd0112a @bep #9313
- basefs: add
noBuildLock
flag 6f7fbe0 @satotake #9780 - import: Fix importing jekyll site 2fc2e9c @satotake #9817
- releaser: Prepare repository for 0.100.0-DEV e164834 @bep
- releaser: Bump versions for release of 0.99.1 d524067 @bep
- releaser: Add release notes for 0.99.1 [ci skip] 31ce89f @bep
- releaser: Fix version replacement ee55fde @bep
- server: Fix multihost crash 2f9eac4 @bep #9901
- Update stale.yml 3a8189e @bep
- common/hugo: Fix version logic 7bc3401 @bep