Print layout name if it was specified when showing missing layout file error
authorAndreas Richter <richtera@users.noreply.github.com>
Sun, 13 Sep 2020 18:36:37 +0000 (14:36 -0400)
committerGitHub <noreply@github.com>
Sun, 13 Sep 2020 18:36:37 +0000 (20:36 +0200)
Fixes #7617

hugolib/site.go
hugolib/site_render.go

index dad5ab538d71a2fffca24a2a69d59c532be75175..b06d5176ba22d978d4ccdd112ff311c3a9daccd3 100644 (file)
@@ -1721,7 +1721,7 @@ func (hr hookRenderer) RenderHeading(w io.Writer, ctx hooks.HeadingContext) erro
 
 func (s *Site) renderForTemplate(name, outputFormat string, d interface{}, w io.Writer, templ tpl.Template) (err error) {
        if templ == nil {
-               s.logMissingLayout(name, "", outputFormat)
+               s.logMissingLayout(name, "", "", outputFormat)
                return nil
        }
 
index 88b5e6fb759774f15e2d751ef5fe2cb16500ea89..d9d60c2fa3eed12e31ef6cbdea36905859ba6be7 100644 (file)
@@ -130,7 +130,7 @@ func pageRenderer(
                }
 
                if !found {
-                       s.logMissingLayout("", p.Kind(), p.f.Name)
+                       s.logMissingLayout("", p.Layout(), p.Kind(), p.f.Name)
                        continue
                }
 
@@ -148,7 +148,7 @@ func pageRenderer(
        }
 }
 
-func (s *Site) logMissingLayout(name, kind, outputFormat string) {
+func (s *Site) logMissingLayout(name, layout, kind, outputFormat string) {
        log := s.Log.WARN
        if name != "" && infoOnMissingLayout[name] {
                log = s.Log.INFO
@@ -162,6 +162,11 @@ func (s *Site) logMissingLayout(name, kind, outputFormat string) {
                args = append(args, outputFormat)
        }
 
+       if layout != "" {
+               msg += " for layout %q"
+               args = append(args, layout)
+       }
+
        if kind != "" {
                msg += " for kind %q"
                args = append(args, kind)