]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
resources/page: Add passing test for Issue #14325
authorJoe Mooring <joe.mooring@veriphor.com>
Fri, 17 Apr 2026 18:47:37 +0000 (11:47 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 18 Apr 2026 13:02:47 +0000 (15:02 +0200)
resources/page/permalinks_integration_test.go

index 08fefeb7cbb0c48de77b1596ca3a955185e85128..7aabb8ee6d596fb6a4014f109e07af92fde1b77e 100644 (file)
@@ -14,6 +14,7 @@
 package page_test
 
 import (
+       "fmt"
        "strings"
        "testing"
 
@@ -435,3 +436,82 @@ title: aBc
        b = hugolib.Test(t, files)
        b.AssertFileExists("public/aBc/index.html", true)
 }
+
+func TestPermalinksTaxonomyAndPageConsistencyIssue14325(t *testing.T) {
+       t.Parallel()
+
+       filesTemplate := `
+-- hugo.toml --
+disableKinds = ['rss','sitemap']
+%s
+-- content/s1/p1.md --
+---
+title: p1
+date: 2026-04-02
+tags: ['tag-a']
+categories: ['category-a']
+---
+%s
+-- layouts/all.html --
+{{ .Title }}|
+`
+
+       tests := []struct {
+               explicitTermContent bool
+               kindSpecificConfig  bool
+       }{
+               {true, true},
+               {false, true},
+               {true, false},
+               {false, false},
+       }
+
+       for _, tt := range tests {
+               name := fmt.Sprintf("explicitTermContent=%t/kindSpecificConfig=%t", tt.explicitTermContent, tt.kindSpecificConfig)
+
+               t.Run(name, func(t *testing.T) {
+                       var permalinkConfig, termContent string
+
+                       if tt.kindSpecificConfig {
+                               permalinkConfig = `
+[permalinks.page]
+s1 = '/:year/:month/:day/:contentbasename/'
+[permalinks.term]
+categories = '/:contentbasename/'
+tags = '/tags/:contentbasename/'`
+                       } else {
+                               permalinkConfig = `
+[permalinks]
+s1 = '/:year/:month/:day/:contentbasename/'
+categories = '/:contentbasename/'
+tags = '/tags/:contentbasename/'`
+                       }
+
+                       if tt.explicitTermContent {
+                               termContent = `
+-- content/categories/category-a/_index.md --
+---
+title: Category A (set in front matter)
+---
+-- content/tags/tag-a/_index.md --
+---
+title: Tag A (set in front matter)
+---`
+                       }
+
+                       f := fmt.Sprintf(filesTemplate, permalinkConfig, termContent)
+                       b := hugolib.Test(t, f)
+
+                       b.AssertFileExists("public/2026/04/02/p1/index.html", true)
+                       b.AssertFileExists("public/categories/index.html", true)
+                       b.AssertFileExists("public/category-a/index.html", true)
+                       b.AssertFileExists("public/index.html", true)
+                       b.AssertFileExists("public/s1/index.html", true)
+                       b.AssertFileExists("public/tags/index.html", true)
+                       b.AssertFileExists("public/tags/tag-a/index.html", true)
+
+                       b.AssertFileExists("public/categories/category-a/index.html", false)
+                       b.AssertFileExists("public/s1/p1/index.html", false)
+               })
+       }
+}