New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to set parent for root-level pages #4447

vassudanagunta opened this Issue Feb 25, 2018 · 0 comments


None yet
2 participants

vassudanagunta commented Feb 25, 2018

func (s *Site) assembleSections() Pages in site_sections.go loops through all of the Site's pages to set the Parent value for each. But as you can see below, it assumes that the home page occurs in the list of pages before any of the root-level pages:

for i, p := range s.Pages {
if p.Kind != KindPage {
if p.Kind == KindHome {
home = p
if len(p.sections) == 0 {
// Root level pages. These will have the home page as their Parent.
p.parent = home

This manifest for me during the automatic rebuild triggered by modification of a root-level page. A panic was generated during the rendering of a template accessing .CurrentSection for that page:

@bep bep changed the title from flawed assumption in Site.assembleSections can fail to set parent for root-level pages to Fail to set parent for root-level pages Feb 25, 2018

@bep bep added this to the v0.37 milestone Feb 25, 2018

@bep bep closed this in #4448 Feb 25, 2018

@bep bep added the Bug label Feb 25, 2018

bep added a commit that referenced this issue Feb 25, 2018

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

bep added a commit that referenced this issue Feb 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment