From: Bjørn Erik Pedersen Date: Tue, 24 Jul 2018 08:10:51 +0000 (+0200) Subject: hugolib: Fix .Site.GetPage regression X-Git-Tag: v0.45.1~4 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=04d4c08dbcac08ff7feeb88863e91799fed0937b;p=brevno-suite%2Fhugo hugolib: Fix .Site.GetPage regression In Hugo 0.44 we simplified the `.Site.GetPage` API and added code to handle the old-style syntax in most cases. This logic did not handle the lookup of the home page via `.Site.GetPage "section" ""` and similar. This commit fixes that. Fixes #4989 --- diff --git a/hugolib/page_collections.go b/hugolib/page_collections.go index d196d67a..d99857ae 100644 --- a/hugolib/page_collections.go +++ b/hugolib/page_collections.go @@ -176,7 +176,14 @@ func (c *PageCollections) getPageOldVersion(ref ...string) (*Page, error) { if len(refs) == 0 || refs[0] == KindHome { key = "/" } else if len(refs) == 1 { - key = refs[0] + if len(ref) == 2 && refs[0] == KindSection { + // This is an old style reference to the "Home Page section". + // Typically fetched via {{ .Site.GetPage "section" .Section }} + // See https://github.com/gohugoio/hugo/issues/4989 + key = "/" + } else { + key = refs[0] + } } else { key = refs[1] } diff --git a/hugolib/site_sections_test.go b/hugolib/site_sections_test.go index bfec623e..86ae4080 100644 --- a/hugolib/site_sections_test.go +++ b/hugolib/site_sections_test.go @@ -109,6 +109,8 @@ Content {{ range .Paginator.Pages }} PAG|{{ .Title }}|{{ $sect.InSection . }} {{ end }} +{{/* https://github.com/gohugoio/hugo/issues/4989 */}} +{{ $sections := (.Site.GetPage "section" .Section).Sections.ByWeight }} `) cfg.Set("paginate", 2)