package page_test
import (
+ "strings"
"testing"
"github.com/gohugoio/hugo/hugolib"
b.AssertFileContentExact("public/index.html", "/|/s1/p%231/|/s2/p%232/|/tags/test%23tag%23/|")
}
+
+func TestOutputFormatWithPathIssue13829(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+uglyURLs = false
+
+[outputFormats.print]
+isPlainText = true
+mediaType = 'text/plain'
+path = 'print'
+
+[outputs]
+home = ['html','print']
+page = ['html','print']
+section = ['html','print']
+taxonomy = ['html','print']
+term = ['html','print']
+
+[taxonomies]
+tag = 'tags'
+-- content/_index.md --
+---
+title: home
+---
+-- content/s1/_index.md --
+---
+title: s1
+---
+-- content/s1/p1.md --
+---
+title: p1
+tags: ['red']
+---
+-- content/tags/_index.md --
+---
+title: tags
+---
+-- content/tags/red/_index.md --
+---
+title: red
+---
+`
+
+ templates := []string{
+ "layouts/home.html",
+ "layouts/home.print.txt",
+ "layouts/page.html",
+ "layouts/page.print.txt",
+ "layouts/section.html",
+ "layouts/section.print.txt",
+ "layouts/taxonomy.html",
+ "layouts/taxonomy.print.txt",
+ "layouts/term.html",
+ "layouts/term.print.txt",
+ }
+
+ const code string = "TITLE: {{ .Title }} | AOFRP: {{ range .AlternativeOutputFormats }}{{ .RelPermalink }}{{ end }} | TEMPLATE: {{ templates.Current.Name }}"
+
+ for _, template := range templates {
+ files += "-- " + template + " --\n" + code + "\n"
+ }
+
+ b := hugolib.Test(t, files)
+
+ // uglyURLs: false, outputFormat: 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/index.html", "TITLE: p1 | AOFRP: /print/s1/p1/index.txt | TEMPLATE: page.html")
+ b.AssertFileContent("public/tags/index.html", "TITLE: tags | AOFRP: /print/tags/index.txt | TEMPLATE: taxonomy.html")
+ b.AssertFileContent("public/tags/red/index.html", "TITLE: red | AOFRP: /print/tags/red/index.txt | TEMPLATE: term.html")
+
+ // uglyURLs: false, outputFormat: print
+ b.AssertFileContent("public/print/index.txt", "TITLE: home | AOFRP: / | TEMPLATE: home.print.txt")
+ b.AssertFileContent("public/print/s1/index.txt", "TITLE: s1 | AOFRP: /s1/ | TEMPLATE: section.print.txt")
+ b.AssertFileContent("public/print/s1/p1/index.txt", "TITLE: p1 | AOFRP: /s1/p1/ | TEMPLATE: page.print.txt")
+ 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")
+ 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/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")
+ b.AssertFileContent("public/tags/red.html", "TITLE: red | AOFRP: /print/tags/red.txt | TEMPLATE: term.html")
+
+ // uglyURLs: true, outputFormat: print
+ b.AssertFileContent("public/print/index.txt", "TITLE: home | AOFRP: /index.html | TEMPLATE: home.print.txt")
+ 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")*/
+}