diff options
author | Vas Sudanagunta <vas@commonkarma.org> | 2018-02-25 01:15:03 -0500 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-02-25 10:34:24 +0100 |
commit | 00868081f624928d773a7b698654766f8cd70069 (patch) | |
tree | 36ef114cc19ffa5f9025c6e2594d4b17ae327315 /hugolib | |
parent | e9750d831f749afa928d8a099af5889d18cb2484 (diff) |
Fix bug in Site.assembleSections method
Site.assembleSections logic assumes that the the home page would always be the first in the Site's list of pages. This is not in fact guaranteed to be true. When it is not, the method can fail to set the parent for some or all root-level pages.
Fixes #4447
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/site_sections.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/hugolib/site_sections.go b/hugolib/site_sections.go index 1a42f7808..5de350b2f 100644 --- a/hugolib/site_sections.go +++ b/hugolib/site_sections.go @@ -167,11 +167,15 @@ func (s *Site) assembleSections() Pages { undecided Pages ) + homes := s.findPagesByKind(KindHome) + if len(homes) == 1 { + home = homes[0] + } else if len(homes) > 1 { + panic("Too many homes") + } + for i, p := range s.Pages { if p.Kind != KindPage { - if p.Kind == KindHome { - home = p - } continue } |