]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
tpl: Fix layout fall back logic when layout is set in front matter but not found
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 21 Apr 2025 09:28:33 +0000 (11:28 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 21 Apr 2025 13:17:20 +0000 (15:17 +0200)
Fixes #13630

tpl/tplimpl/templatedescriptor.go
tpl/tplimpl/templatestore_integration_test.go

index ca73c9f783299512f629dceceb2c170589d60618..8b50605ac8fbd65aefa8aea000b75982556a61b1 100644 (file)
@@ -94,14 +94,10 @@ func (this TemplateDescriptor) doCompare(category Category, isEmbedded bool, oth
        }
 
        if other.LayoutFromTemplate != "" && other.LayoutFromTemplate != layoutAll {
-               if this.LayoutFromUser == "" {
+               if this.LayoutFromUser == "" || this.LayoutFromUser != other.LayoutFromTemplate {
                        if other.LayoutFromTemplate != this.LayoutFromTemplate {
                                return w
                        }
-               } else if isLayoutStandard(this.LayoutFromUser) {
-                       if other.LayoutFromTemplate != this.LayoutFromUser {
-                               return w
-                       }
                }
        }
 
index 375813c31e839e1c2a380729ade36cb99860f4fc..51b28754fa09824648f7ce19cf774b7174657140 100644 (file)
@@ -1245,3 +1245,28 @@ p: {{ partial "p.html" . }}
        b.Assert(err, qt.IsNotNil)
        b.Assert(err.Error(), qt.Contains, "error calling partial: maximum template call stack size exceeded")
 }
+
+func TestIssue13630(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+disableKinds = ['rss','sitemap']
+-- content/p1.md --
+---
+title: p1
+layout: foo
+---
+-- layouts/list.html --
+layouts/list.html
+-- layouts/taxononmy.html.html --
+layouts/taxononmy.html.html
+`
+
+       var b *hugolib.IntegrationTestBuilder
+
+       for range 3 {
+               b = hugolib.Test(t, files)
+               b.AssertFileExists("public/p1/index.html", false)
+       }
+}