hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 555a5612b2641075b3e1b3b7af8ce9b5aba9f200
parent 75e54345f9a7d786bb28af64ad80eb9502fee7c7
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Fri, 14 Sep 2018 11:04:33 +0200

hugolib: Do not set RSS as Kind in RSS output

Before Hugo this commit  we set the pseudo page kind RSS on the page when output to RSS. This had some unintended side effects, esp. when the only output format for that page  was RSS.

For the page kinds that can have multiple output formats, the Kind should be one of the standard home, page etc.

Fixes #5138

Diffstat:
Mhugolib/rss_test.go | 18++++++++++++++++++
Mhugolib/site_render.go | 2--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/hugolib/rss_test.go b/hugolib/rss_test.go
@@ -57,3 +57,21 @@ func TestRSSOutput(t *testing.T) {
 		t.Errorf("incorrect RSS item count: expected %d, got %d", rssLimit, c)
 	}
 }
+
+// Before Hugo 0.49 we set the pseudo page kind RSS on the page when output to RSS.
+// This had some unintended side effects, esp. when the only output format for that page
+// was RSS.
+// For the page kinds that can have multiple output formats, the Kind should be one of the
+// standard home, page etc.
+// This test has this single purpose: Check that the Kind is that of the source page.
+// See https://github.com/gohugoio/hugo/issues/5138
+func TestRSSKind(t *testing.T) {
+	t.Parallel()
+
+	b := newTestSitesBuilder(t)
+	b.WithSimpleConfigFile().WithTemplatesAdded("index.rss.xml", `RSS Kind: {{ .Kind }}`)
+
+	b.Build(BuildCfg{})
+
+	b.AssertFileContent("public/index.xml", "RSS Kind: home")
+}
diff --git a/hugolib/site_render.go b/hugolib/site_render.go
@@ -248,8 +248,6 @@ func (s *Site) renderRSS(p *PageOutput) error {
 		return nil
 	}
 
-	p.Kind = kindRSS
-
 	limit := s.Cfg.GetInt("rssLimit")
 	if limit >= 0 && len(p.Pages) > limit {
 		p.Pages = p.Pages[:limit]