diff --git a/hugolib/page_collections.go b/hugolib/page_collections.go index 3bdb4d9ce..157d4e68d 100644 --- a/hugolib/page_collections.go +++ b/hugolib/page_collections.go @@ -152,6 +152,15 @@ func (*PageCollections) findPagesByKindIn(kind string, inPages Pages) Pages { return pages } +func (*PageCollections) findFirstPageByKindIn(kind string, inPages Pages) *Page { + for _, p := range inPages { + if p.Kind == kind { + return p + } + } + return nil +} + func (*PageCollections) findPagesByKindNotIn(kind string, inPages Pages) Pages { var pages Pages for _, p := range inPages { diff --git a/hugolib/site_sections.go b/hugolib/site_sections.go index 5de350b2f..c8bca03e3 100644 --- a/hugolib/site_sections.go +++ b/hugolib/site_sections.go @@ -161,18 +161,12 @@ func (s *Site) assembleSections() Pages { ) var ( - home *Page inPages = radix.New().Txn() inSections = radix.New().Txn() undecided Pages ) - homes := s.findPagesByKind(KindHome) - if len(homes) == 1 { - home = homes[0] - } else if len(homes) > 1 { - panic("Too many homes") - } + home := s.findFirstPageByKindIn(KindHome, s.Pages) for i, p := range s.Pages { if p.Kind != KindPage {