Custom sitemap

Thanks to the docs and this forum, I tried to build a custom sitemap as follows:

<urlset xmlns="">
  	{{- range .Site.Home.Sections.ByTitle }}
  <li>{{- template "section-tree-nav" .}}</li>
{{- end}}
{{- define "section-tree-nav" }}
  {{- if .IsSection }}
    {{- range .Sections.ByTitle }}
      <li>{{- template "section-tree-nav" . }}</li>
    {{- end }}
    {{- range .Pages.ByTitle }}
      {{- template "section-tree-nav" . }}
    {{- end}}
  {{- else}}
  {{- end}}
{{- end}}

I have the following questions (since it’s not the Hugo’s built-in template file):

  • Is this sitemap valid?
  • Is it possible to apply a style to this sitemap and how to do it?
  • assuming that the sitemap is submiited to Google what is the best option to do it?

Note that I put the sitemap.xml in themes/my-theme/layouts and I put in config.toml the following code:

      changefreq = "weekly"
      priority = 0.5
      filename = "sitemap.xml"

I cannot test whether your sitemap is valid right now. But why style it? It’s a plain xml.

To submit it to Google you need to set up the Search Console for your site.

Please use a sitemap validator.

These are questions best answered elsewhere, since they have to do with a core search engine technology and a search company.

If you have any Hugo-specific questions, please start a new thread. :slight_smile: