Thanks to the docs and this forum, I tried to build a custom sitemap as follows:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<nav>
<ul>
{{- range .Site.Home.Sections.ByTitle }}
<li>{{- template "section-tree-nav" .}}</li>
{{- end}}
{{- define "section-tree-nav" }}
{{- if .IsSection }}
{{.Title}}
<ul>
{{- range .Sections.ByTitle }}
<li>{{- template "section-tree-nav" . }}</li>
{{- end }}
{{- range .Pages.ByTitle }}
{{- template "section-tree-nav" . }}
{{- end}}
</ul>
{{- else}}
<li>{{.LinkTitle}}</li>
{{- end}}
{{- end}}
</ul>
</nav>
</urlset>
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:
[sitemap]
changefreq = "weekly"
priority = 0.5
filename = "sitemap.xml"