The problem:
I can’t remove <lastmod>
from the main sitemap under the root.
My Hugo is multilang, so it wont create a typical sitemap with all the post URLs under the root, instead it will list sitemap URLs for each language. This is how it looks like:
I highlighted on yellow the part I am trying to get rid of - the <lastmod>
. I managed to remove it from the sitemap for each language sitemap by exposing the sitemap template that currently sits in layouts/_default/sitemap.xml
and looks like this:
{{ 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 .Data.Pages }}
{{- if .Permalink -}}
<url>
<loc>{{ .Permalink }}</loc>{{ 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.Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Language.Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
</url>
{{- end -}}
{{ end }}
</urlset>
So that’s good and I am half-way home.
Solutions I tried:
Creating additional template for sitemap with name layouts/_default/home.sitemap.xml
- it did not work.
How can I remove the lastmod for the root sitemap for multilang site?
UPDATE: I think I managed to expose the main sitemap by creating additional file layouts/_default/sitemapindex.xml
, however, I am having trouble populating it correctly so it can look exactly as on the screenshot above minus the line.