Skip to content

Commit

Permalink
Fix bug in Site.assembleSections method
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vassudanagunta authored and bep committed Feb 25, 2018
1 parent e9750d8 commit 0086808
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hugolib/site_sections.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 0086808

Please sign in to comment.