Changing sitemap.xml to show posts from a category

Below is the default template for sitemap.xml on my Micro.blog blog. I’d like to change it so that, instead of listing all posts, it lists only those in the category “newsletter”. Unfortunately I can’t seem to get the hang of categories. Clearly I need to replace the line {{ $list := (where .Site.Pages "Type" "post") }}, but I can’t figure out what to replace it with. Any suggestions will be gratefully received.

{{ "<" | safeHTML }}?xml version="1.0" encoding="UTF-8"{{ "?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
	{{ $list := (where .Site.Pages "Type" "post") }}
	{{- $list := $list | union (where .Site.Pages ".Params.menu" "main") -}}
	{{- range $list -}}
		<url>
			<loc>{{ .Permalink }}</loc>
			<lastmod>{{ .Date.Format "2006-01-02T15:04:05-07:00" }}</lastmod>
		</url>
	{{ end }}
</urlset>

{{$newsletters := where $list "Params.categories" "intersect" (slice "newsletter") }}

I’m not sure what the fourth line is meant to do, but the third line makes $list with all your posts, and if you do my line above, it’ll filter $list to those where it has “newsletter” as a category. Then just refer to $newsletters.

Curious to edit the sitemap to not include some pages. I think this basically only serves to either downrank or make it slightly harder for Google and other search crawlers to find the individual post pages, but does not, at all, restrict them.

Thank you for this. I’m not at all sure that confining the sitemap to newsletter pages is the right way to go about this, but I thought I’d experiment. I want searchers to be able to find my newsletter pages; ordinary microposts, which might be on a range of topics, could just be confusing the issue. But I can see why this approach might not be a good idea.

I think what the fourth line is doing is adding the pages that appear in the navigation menu to the list. (I didn’t write or change this template: it came with the default theme.)

I think the problem probably wasn’t with my sitemap after all. I thought I had submitted the URLs of some pages which are essentially indexes of the newsletter posts, and was puzzled as to why the posts weren’t showing up in searches, but it seems that I hadn’t submitted the pages after all. Thanks again for the help.