Disable page from sitemap

Hello. I have some content and Sections witch I must disable from the sitemap. How can I do that?

Copy the embedded sitemap template to layouts/_default/sitemap.xml.

Then modify the page selection criteria:

{{ range where .Pages "Params.sitemap_exclude" "ne" true }}

To exclude a page:

title = 'Article 3'
date = 2022-02-17T09:02:48-08:00
draft = false
sitemap_exclude = true

There’s a stale PR that would simplify this:
https://github.com/gohugoio/hugo/pull/6370

1 Like

Thank u. I added the new file sitemap.xml to the folder layouts/_default/ and this file did not affect the generation of the sitemap(
HUGO 0.92.2

1 Like

It works fine. Try it:

git clone --single-branch -b hugo-forum-topic-37213 https://github.com/jmooring/hugo-testing hugo-forum-topic-37213
cd hugo-forum-topic-37213
hugo && rm -rf public && grep post-2 public/sitemap.xml 
1 Like

Thanks. It turns out that I had a sitemap.xml file in the layouts folder and it interfered.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.