Skip to content

Commit 2d3189b

Browse files
committed
hugolib: Fix handling of mixed-case taxonomy folders with content file
* We match by path vs taxonomy to determine if we have a content page for that taxonomy * The taxonomy name is (if `preserveTaxonomyNames` is not set) normalized to `maxmustermann` while you have the disk folder called `MaxMustermann`. * This isn't a new issue, but I suspect most people will just name the folder `authors/maxmustermann` and it will just work. * The inconsistent behaviour you see here is that you will end up with two pages with the same target filename, so it is a little random who will win. This fixes that by also normalizing the taxonomy path when doing the comparison. Fixes #4238
1 parent 4b04db0 commit 2d3189b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

‎hugolib/hugo_sites.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,11 @@ func (h *HugoSites) createMissingPages() error {
440440
key = s.PathSpec.MakePathSanitized(key)
441441
}
442442
for _, p := range taxonomyPages {
443-
if p.sections[0] == plural && p.sections[1] == key {
443+
// Some people may have /authors/MaxMustermann etc. as paths.
444+
// p.sections contains the raw values from the file system.
445+
// See https://github.com/gohugoio/hugo/issues/4238
446+
singularKey := s.PathSpec.MakePathSanitized(p.sections[1])
447+
if p.sections[0] == plural && singularKey == key {
444448
foundTaxonomyPage = true
445449
break
446450
}

‎hugolib/taxonomy_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ permalinkeds:
116116
writeSource(t, fs, "content/p4.md", fmt.Sprintf(pageTemplate, "Hello World", "", "", "- \"Hello Hugo world\"", "- pl1"))
117117

118118
writeNewContentFile(t, fs, "Category Terms", "2017-01-01", "content/categories/_index.md", 10)
119-
writeNewContentFile(t, fs, "Tag1 List", "2017-01-01", "content/tags/tag1/_index.md", 10)
119+
writeNewContentFile(t, fs, "Tag1 List", "2017-01-01", "content/tags/Tag1/_index.md", 10)
120120

121121
err := h.Build(BuildCfg{})
122122

0 commit comments

Comments
 (0)