From 17f851780c79d0223b247dadcd8ddec0c74c4500 Mon Sep 17 00:00:00 2001 From: Cameron Moore Date: Mon, 26 Dec 2016 20:36:08 -0600 Subject: [PATCH] hugolib: Fix redundant URL file extension on taxonomy terms pages Fixes #2819 --- hugolib/node_as_page_test.go | 13 +++++++++++++ hugolib/page.go | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hugolib/node_as_page_test.go b/hugolib/node_as_page_test.go index 5cca25fb5..9836d92a2 100644 --- a/hugolib/node_as_page_test.go +++ b/hugolib/node_as_page_test.go @@ -222,6 +222,19 @@ func doTestNodesWithNoContentFile(t *testing.T, ugly bool) { "Taxonomy Terms Title: Categories", ) + pages := s.findPagesByKind(KindTaxonomyTerm) + for _, p := range pages { + var want string + if ugly { + want = "/" + p.Site.pathSpec.URLize(p.Title) + ".html" + } else { + want = "/" + p.Site.pathSpec.URLize(p.Title) + "/" + } + if p.URL() != want { + t.Errorf("Taxonomy term URL mismatch: want %q, got %q", want, p.URL()) + } + } + // Sections assertFileContent(t, expectedFilePath(ugly, "public", "sect1"), false, "Section Title: Sect1s", diff --git a/hugolib/page.go b/hugolib/page.go index 1681216bc..06daf97bc 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -758,7 +758,7 @@ func (p *Page) createPermalink() (*url.URL, error) { // No permalink config for nodes (currently) pURL := strings.TrimSpace(p.Site.pathSpec.URLize(p.URLPath.URL)) pURL = p.addLangPathPrefix(pURL) - pURL = p.Site.pathSpec.URLPrep(path.Join(pURL, "index."+p.Extension())) + pURL = p.Site.pathSpec.URLPrep(pURL) url := helpers.MakePermalink(baseURL, pURL) return url, nil }