summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-05-02 09:54:26 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-05-02 14:23:16 +0200
commit6b76841b052b97625b8995f326d758b89f5c2349 (patch)
tree0a29c666b6e11e6c73f64da4beb0ca86d3965da5 /hugolib
parentbcbed4ebdaf55b67abc521d69bba456c041a7e7d (diff)
output: Fix permalink in sitemap etc. when multiple permalinkable output formats
In Hugo 0.55.0 we made AMP `permalinkable`. We also render the output formats in their natural sort order, meaning `AMP` will be rendered before `HTML`. References in the sitemap would then point to the AMP version, and this is normally not what you'd want. This commit fixes that by making `HTML` by default sort before the others. If this is not you want, you can set `weight` on the output format configuration. Fixes #5910
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/site_render.go2
-rw-r--r--hugolib/sitemap_test.go19
2 files changed, 20 insertions, 1 deletions
diff --git a/hugolib/site_render.go b/hugolib/site_render.go
index 9ade951df..34f288da2 100644
--- a/hugolib/site_render.go
+++ b/hugolib/site_render.go
@@ -35,7 +35,7 @@ type siteRenderContext struct {
sitesOutIdx int
// Zero based index of the output formats configured within a Site.
- // Note that these outputs are sorted, so CSS will come before HTML.
+ // Note that these outputs are sorted.
outIdx int
multihost bool
diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go
index cab13d356..5aba6f09d 100644
--- a/hugolib/sitemap_test.go
+++ b/hugolib/sitemap_test.go
@@ -100,3 +100,22 @@ func TestParseSitemap(t *testing.T) {
}
}
+
+// https://github.com/gohugoio/hugo/issues/5910
+func TestSitemapOutputFormats(t *testing.T) {
+
+ b := newTestSitesBuilder(t).WithSimpleConfigFile()
+
+ b.WithContent("blog/html-amp.md", `
+---
+Title: AMP and HTML
+outputs: [ "html", "amp" ]
+---
+
+`)
+
+ b.Build(BuildCfg{})
+
+ // Should link to the HTML version.
+ b.AssertFileContent("public/sitemap.xml", " <loc>http://example.com/blog/html-amp/</loc>")
+}