shithub: hugo

Download patch

ref: 9df60b62f9c4e36a269f0c6e9a69bee9dc691031
parent: 4fad43c8bd528f1805e78c50cd2e33822351c183
author: Andreas Richter <richtera@users.noreply.github.com>
date: Sun Sep 13 10:36:37 EDT 2020

Print layout name if it was specified when showing missing layout file error

Fixes #7617

--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -1721,7 +1721,7 @@
 
 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
 	}
 
--- a/hugolib/site_render.go
+++ b/hugolib/site_render.go
@@ -130,7 +130,7 @@
 		}
 
 		if !found {
-			s.logMissingLayout("", p.Kind(), p.f.Name)
+			s.logMissingLayout("", p.Layout(), p.Kind(), p.f.Name)
 			continue
 		}
 
@@ -148,7 +148,7 @@
 	}
 }
 
-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
@@ -160,6 +160,11 @@
 	if outputFormat != "" {
 		msg += " %q"
 		args = append(args, outputFormat)
+	}
+
+	if layout != "" {
+		msg += " for layout %q"
+		args = append(args, layout)
 	}
 
 	if kind != "" {