Add custom sitemap


im trying to add another sitemap so i have 2 different sitemaps
im following the examples at

i have added sitemap2.xml in layouts/_default/ but hugo does not create the file sitemap2.xml

i have copied the sample config:

{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<urlset xmlns=""
  {{ range .Data.Pages }}
    <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 }}
                hreflang="{{ .Lang }}"
                href="{{ .Permalink }}"
                />{{ end }}
                hreflang="{{ .Lang }}"
                href="{{ .Permalink }}"
                />{{ end }}
  {{ end }}

But it doesnt work, what am i doing wrong? do i need to add some variable in the config file?

Ok, this is a template - not a config :wink:

You must tell hugo to generate a second sitemap like this

    MediaType              = "application/xml"
    BaseName               = "sitemap2"
    IsHTML                 = false
    IsPlainText            = true
    Rel                    = "sitemap"

    home                   = [ "HTML", "SITEMAP", "SITEMAP2"]
1 Like