Disable index some Section's pages

Hello. I have Section “press” and I use only the main section page. All subpages don’t need. How can I exclude subpages from sitemap? Or maybe I can add the options which will be disabled the compilation these pages?

For example, I need only
site.ru/press/
site.ru/de/press/

But I didn’t need
site.ru/press/lala/
site.ru/de/press/lala/

I used this way in home.sitemap.xml

{{ range (where site.RegularPages "Section" "not in" site.Params.invisibleSections) }}

and in config:

invisibleSections = ["menu","intern","test","about"]

Should give you a starting point

you could explicitly tell pages not to index, ie: index: false in params and then edit sitemap.xml like this

{{ range (where .Data.Pages "Params.index" "eq" nil) | union (where .Data.Pages "Params.index" "eq" true) }}

you can even use cascade params to set per section

Isn’t an XML sitemap generated automatically? How can we influence her?

you can override internal layout by placing sitemap.xml file into layout folder

This is a very bad option. My pages are added every day and how then to control the sitemap?

no, you dont get it. There will be no content in sitemap.xml template. There will be just altered loop and markup. Final sitemap.xml will be generated after each content update.

Fantastic!
My case. I created the custom templates via this https://gohugo.io/templates/sitemap-template/#hugo-s-sitemap-xml and changed the condition.