diff --git a/hugolib/page__per_output.go b/hugolib/page__per_output.go index 9009165ff..e8dd38ce7 100644 --- a/hugolib/page__per_output.go +++ b/hugolib/page__per_output.go @@ -114,7 +114,7 @@ func (pco *pageContentOutput) Render(ctx context.Context, layout ...string) (tem } if !found { - return "", nil + return "", fmt.Errorf("template %q not found", layout[0]) } // Make sure to send the *pageState and not the *pageContentOutput to the template. diff --git a/hugolib/page_test.go b/hugolib/page_test.go index f6225cac5..803dddc01 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -2055,3 +2055,21 @@ disableKinds = ["taxonomy", "term"] } } } + +// See issue 15052. +func TestRenderViewNotFound(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +disableKinds = ['page','rss','section','sitemap','taxonomy','term'] +-- layouts/home.html -- +{{ .Render "view_foo" }} +{{ .Render "view_bar" }} +-- layouts/view_foo.html -- +foo +` + + b, err := TestE(t, files) + b.Assert(err, qt.ErrorMatches, `.*template "view_bar" not found.*`) +} diff --git a/tpl/page/page_integration_test.go b/tpl/page/page_integration_test.go index 817033b40..da18f553e 100644 --- a/tpl/page/page_integration_test.go +++ b/tpl/page/page_integration_test.go @@ -77,7 +77,7 @@ Image OK. {{ if page.IsHome }} Link OK. {{ end }} --- layouts/myview.html +-- layouts/myview.html -- {{ if page.IsHome }} Render OK. {{ end }}