aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorJoe Mooring <[email protected]>2024-04-01 15:30:03 -0700
committerBjørn Erik Pedersen <[email protected]>2024-04-02 11:21:03 +0200
commit6738a3e79dd545603d9851832bc3140fd184bfef (patch)
tree9faff4e6a3fed40c8c9f59df19fd296c48ad49ef /hugolib
parent2f7df4b926fe20849e9030edfe9b1d94b8cadfa9 (diff)
downloadhugo-6738a3e79dd545603d9851832bc3140fd184bfef.tar.gz
hugo-6738a3e79dd545603d9851832bc3140fd184bfef.zip
tpl/tplimpl: Optionally exclude content from sitemap
Define global inclusion/exclusion in site configuration, and override via front matter. For example, to exclude a page from the sitemap: [sitemap] disable = true # default is false Closes #653 Closes #12282 Co-authored-by: kolappannathan <[email protected]> Co-authored-by: felicianotech <[email protected]>
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/config_test.go5
-rw-r--r--hugolib/sitemap_test.go5
2 files changed, 5 insertions, 5 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go
index 22beea655..8acf8b36e 100644
--- a/hugolib/config_test.go
+++ b/hugolib/config_test.go
@@ -490,11 +490,10 @@ name = "menu-theme"
got := b.Configs.Base
if mergeStrategy == "none" {
- b.Assert(got.Sitemap, qt.DeepEquals, config.SitemapConfig{ChangeFreq: "", Priority: -1, Filename: "sitemap.xml"})
-
+ b.Assert(got.Sitemap, qt.DeepEquals, config.SitemapConfig{ChangeFreq: "", Disable: false, Priority: -1, Filename: "sitemap.xml"})
b.AssertFileContent("public/sitemap.xml", "schemas/sitemap")
} else {
- b.Assert(got.Sitemap, qt.DeepEquals, config.SitemapConfig{ChangeFreq: "monthly", Priority: -1, Filename: "sitemap.xml"})
+ b.Assert(got.Sitemap, qt.DeepEquals, config.SitemapConfig{ChangeFreq: "monthly", Disable: false, Priority: -1, Filename: "sitemap.xml"})
b.AssertFileContent("public/sitemap.xml", "<changefreq>monthly</changefreq>")
}
})
diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go
index a5a94c67e..1c2642468 100644
--- a/hugolib/sitemap_test.go
+++ b/hugolib/sitemap_test.go
@@ -108,11 +108,12 @@ outputs: [ "html", "amp" ]
func TestParseSitemap(t *testing.T) {
t.Parallel()
- expected := config.SitemapConfig{Priority: 3.0, Filename: "doo.xml", ChangeFreq: "3"}
+ expected := config.SitemapConfig{ChangeFreq: "3", Disable: true, Filename: "doo.xml", Priority: 3.0}
input := map[string]any{
"changefreq": "3",
- "priority": 3.0,
+ "disable": true,
"filename": "doo.xml",
+ "priority": 3.0,
"unknown": "ignore",
}
result, err := config.DecodeSitemap(config.SitemapConfig{}, input)