Hugo 0.45: Revival of ref, relref and GetPage

gohugo
Tags: #<Tag:0x00007f21aef7b468>

#1

I suggest reading the notes, it changes how ref and relref work, and it actually simplifies it drastically!

Before this release, the API was a little bit clumsy and the result potentially ambiguous in some situations.

Now you can simply do:

{{ with .Site.GetPage "/blog/my-post.md" }}{{ .Title }}{{ end }}

Or to get a section page:

{{ with .Site.GetPage "/blog" }}{{ .Title }}{{ end }}

We have also added a .GetPage method on Page and added support for page-relative linking. This means that the leading slash (/) now has a meaning. For .Site.GetPage, all lookups will start at the content root. But for lookups with a Page context, paths without a leading slash will be treated as relative to the page.


#2

Add Page.FirstSection

Fun related quote: