Restrict the new type layout resolution to page and section kinds
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 30 Jun 2018 14:50:02 +0000 (16:50 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 30 Jun 2018 14:50:02 +0000 (16:50 +0200)
Will have to test and evaluate this a little.

See  #4891

hugolib/page.go

index 458b96b285601b041eb1b196c3ae541d71f60bdc..13907c39ec47b9bc316b4dd521df9669ccfdc7ac 100644 (file)
@@ -407,14 +407,16 @@ func (p *Page) createLayoutDescriptor() output.LayoutDescriptor {
 
        var typeCurrentSection string
        var typeRootSection string
-       curr := p.CurrentSection()
-       // Make sure we use the contentType only. This is the value from front matter.
-       if curr != nil {
-               typeCurrentSection = curr.contentType
-       }
-       first := p.FirstSection()
-       if first != nil {
-               typeRootSection = first.contentType
+       if p.Kind == KindPage || p.Kind == KindSection {
+               curr := p.CurrentSection()
+               // Make sure we use the contentType only. This is the value from front matter.
+               if curr != nil {
+                       typeCurrentSection = curr.contentType
+               }
+               first := p.FirstSection()
+               if first != nil {
+                       typeRootSection = first.contentType
+               }
        }
 
        return output.LayoutDescriptor{