]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Revert "resources/page: Fix slugorcontentbasename for section pages"
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 30 Dec 2025 11:57:00 +0000 (12:57 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 30 Dec 2025 15:00:37 +0000 (16:00 +0100)
This reverts commit 25c7c18f9f8862f756835d3ac3faa4f114c344f6.

See #14104
See #14325

resources/page/permalinks.go
resources/page/permalinks_integration_test.go

index 49dc815d11f939f4ec6f9ac5ff06a610510118ac..1d6078b4ab4c3d132a691b7791f31b243427f46b 100644 (file)
@@ -336,11 +336,6 @@ func (l PermalinkExpander) pageToPermalinkSectionSlugs(p Page, attr string) (str
 
 // pageToPermalinkContentBaseName returns the URL-safe form of the content base name.
 func (l PermalinkExpander) pageToPermalinkContentBaseName(p Page, _ string) (string, error) {
-       // For section pages with _index.md files, return empty string to match the behavior of pageToPermalinkFilename.
-       // Sections without files should use their directory name.
-       if p.PathInfo().IsBranchBundle() && p.File() != nil {
-               return "", nil
-       }
        return l.urlize(p.PathInfo().Unnormalized().BaseNameNoIdentifier()), nil
 }
 
index 29bb55557f25b10917fc4a8c35bf316ac169a8ac..b33c599a7c75640e50215fc09406179e0d30c947 100644 (file)
@@ -457,39 +457,3 @@ title: aBc
        b = hugolib.Test(t, files)
        b.AssertFileExists("public/aBc/index.html", true)
 }
-
-// Issue 14104
-func TestIssue14104(t *testing.T) {
-       t.Parallel()
-
-       files := `
--- hugo.toml --
-[permalinks.page]
-foo = "/:sections[1:]/:slugorcontentbasename/"
-[permalinks.section]
-foo = "/:sections[1:]/:slugorcontentbasename/"
--- content/foo/_index.md --
----
-title: Foo
----
--- content/foo/bar/_index.md --
----
-title: Bar
----
--- content/foo/bar/somepage.md --
----
-title: Some Page
----
--- layouts/list.html --
-List|{{ .Kind }}|{{ .RelPermalink }}|
--- layouts/single.html --
-Single|{{ .Kind }}|{{ .RelPermalink }}|
-`
-
-       b := hugolib.Test(t, files)
-
-       // Section page should be at /bar/index.html, not /bar/bar/index.html
-       b.AssertFileContent("public/bar/index.html", "List|section|/bar/|")
-       // Regular page should be at /bar/somepage/index.html
-       b.AssertFileContent("public/bar/somepage/index.html", "Single|page|/bar/somepage/|")
-}