Fix some uglyURLs issues for home, section and taxonomy kind (note)

Fixes #4428
Fixes #7497

Co-authored-by: Joe Mooring <joe.mooring@veriphor.com>
This commit is contained in:
Bjørn Erik Pedersen
2025-07-05 12:13:34 +02:00
parent f967212b72
commit b8ba33ca95
4 changed files with 27 additions and 168 deletions

View File

@@ -55,10 +55,11 @@ title: p#2
b.AssertFileContentExact("public/index.html", "/|/s1/p%231/|/s2/p%232/|/tags/test%23tag%23/|")
}
func TestOutputFormatWithPathIssue13829(t *testing.T) {
// Issues: 13829, 4428, 7497.
func TestMiscPathIssues(t *testing.T) {
t.Parallel()
files := `
filesTemplate := `
-- hugo.toml --
uglyURLs = false
@@ -115,9 +116,11 @@ title: red
const code string = "TITLE: {{ .Title }} | AOFRP: {{ range .AlternativeOutputFormats }}{{ .RelPermalink }}{{ end }} | TEMPLATE: {{ templates.Current.Name }}"
for _, template := range templates {
files += "-- " + template + " --\n" + code + "\n"
filesTemplate += "-- " + template + " --\n" + code + "\n"
}
files := filesTemplate
b := hugolib.Test(t, files)
// uglyURLs: false, outputFormat: html
@@ -134,14 +137,11 @@ title: red
b.AssertFileContent("public/print/tags/index.txt", "TITLE: tags | AOFRP: /tags/ | TEMPLATE: taxonomy.print.txt")
b.AssertFileContent("public/print/tags/red/index.txt", "TITLE: red | AOFRP: /tags/red/ | TEMPLATE: term.print.txt")
files = strings.ReplaceAll(files, "uglyURLs = false", "uglyURLs = true")
files = strings.ReplaceAll(filesTemplate, "uglyURLs = false", "uglyURLs = true")
b = hugolib.Test(t, files)
// The assertions below assume that https://github.com/gohugoio/hugo/issues/4428
// and https://github.com/gohugoio/hugo/issues/7497 have been fixed.
// uglyURLs: true, outputFormat: html
/*b.AssertFileContent("public/index.html", "TITLE: home | AOFRP: /print/index.txt | TEMPLATE: home.html")
b.AssertFileContent("public/index.html", "TITLE: home | AOFRP: /print/index.txt | TEMPLATE: home.html")
b.AssertFileContent("public/s1/index.html", "TITLE: s1 | AOFRP: /print/s1/index.txt | TEMPLATE: section.html")
b.AssertFileContent("public/s1/p1.html", "TITLE: p1 | AOFRP: /print/s1/p1.txt | TEMPLATE: page.html")
b.AssertFileContent("public/tags/index.html", "TITLE: tags | AOFRP: /print/tags/index.txt | TEMPLATE: taxonomy.html")
@@ -152,5 +152,5 @@ title: red
b.AssertFileContent("public/print/s1/index.txt", "TITLE: s1 | AOFRP: /s1/index.html | TEMPLATE: section.print.txt")
b.AssertFileContent("public/print/s1/p1.txt", "TITLE: p1 | AOFRP: /s1/p1.html | TEMPLATE: page.print.txt")
b.AssertFileContent("public/print/tags/index.txt", "TITLE: tags | AOFRP: /tags/index.html | TEMPLATE: taxonomy.print.txt")
b.AssertFileContent("public/print/tags/red.txt", "TITLE: red | AOFRP: /tags/red.html | TEMPLATE: term.print.txt")*/
b.AssertFileContent("public/print/tags/red.txt", "TITLE: red | AOFRP: /tags/red.html | TEMPLATE: term.print.txt")
}