diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-12-13 11:52:26 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-12-14 10:29:32 +0100 |
commit | 9ce0a1fb7011bd75eb0e2262e35354c49ce98ac5 (patch) | |
tree | c3ff6ae598ec5dcf022c05b8b076e93922caafb3 /hugolib/hugo_sites.go | |
parent | ab9214768de4ce10032d3fe7ec8c7b2932ead892 (diff) |
hugolib: Restore taxonomy term path separation
Fixes #5513
Diffstat (limited to 'hugolib/hugo_sites.go')
-rw-r--r-- | hugolib/hugo_sites.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index 5e75135c0..c1fa7979c 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -16,6 +16,7 @@ package hugolib import ( "errors" "io" + "path" "path/filepath" "sort" "strings" @@ -520,6 +521,15 @@ func (h *HugoSites) assignMissingTranslations() error { func (h *HugoSites) createMissingPages() error { var newPages Pages + singularPlural := func(p *Page) (string, string) { + slen := len(p.sections) + singular := p.sections[slen-1] + singular = p.s.PathSpec.MakePathSanitized(singular) + plural := path.Join((p.sections[:slen-1])...) + + return singular, plural + } + for _, s := range h.Sites { if s.isEnabled(KindHome) { // home pages @@ -544,6 +554,7 @@ func (h *HugoSites) createMissingPages() error { if len(taxonomies) > 0 { taxonomyPages := s.findPagesByKind(KindTaxonomy) taxonomyTermsPages := s.findPagesByKind(KindTaxonomyTerm) + for _, plural := range taxonomies { if s.isEnabled(KindTaxonomyTerm) { foundTaxonomyTermsPage := false @@ -570,11 +581,10 @@ func (h *HugoSites) createMissingPages() error { key = s.PathSpec.MakeSegment(key) } for _, p := range taxonomyPages { - // Some people may have /authors/MaxMustermann etc. as paths. - // p.sections contains the raw values from the file system. - // See https://github.com/gohugoio/hugo/issues/4238 - singularKey := s.PathSpec.MakePathSanitized(p.sections[1]) - if p.sections[0] == plural && singularKey == key { + + singularKey, pluralKey := singularPlural(p) + + if pluralKey == plural && singularKey == key { foundTaxonomyPage = true break } |