Question 1: Do I need to include into sitemap things like ‘posts’, ‘tags’, ‘categories’ or is it better to exclude them?
Question 2: Do I need to include ‘x-default’ hreflang attribute into sitemap?
Question 3: Do I need to include language versions links to sitemap at all?
Because in my Public folder there are folders for each language versions and inside every such folder there is separate sitemap.xml file. So maybe I just need one URL (without hreflang) in sitemaps?
Sitemap shall include your posts and all pages that you think are important for users to read.You can ignore tags, unless you doing smart tag usage to group articles together, simillar to categories.
I don’t see need to include x-default there as this is not a place for them.
When you enable Hugo multilingual, hugo is creating sitemap index file in root (sitemap.xml with template sitemapindex.xml) and in each language folder proper sitemap.xml (with sitemap.xml template)
My sitemap.xml template used on my multilingial site:
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range where .Pages "Sitemap.Disable" "ne" true }}
{{- if .Permalink -}}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
<xhtml:link
rel="alternate"
hreflang="{{ .Language.LanguageCode }}"
href="{{ .Permalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Language.LanguageCode }}"
href="{{ .Permalink }}"
/>{{ end }}
</url>
{{- end -}}
{{ end }}
</urlset>
Thanks, @idarek !
Good to know about x-default and what to include and what not.
So you do include language versions in sitemap.xml in each language folder.
Anyway, your reply is great food for thought.