Sitemap on version 106 hugo on windows 10

Hi! I need help.
I have version 106 hugo.

link uk ru and en not correct. How i can make template with the code?

I found such code

{{- $multilingual := .Site.Params.languages -}}
{{- range $lang := .Site.Languages -}}
{{- $curLang := (print $lang.Lang “/” ) -}}
{{- $.Scratch.Set “pages” slice -}}
{{- range $.Site.Pages -}}
{{- if eq $curLang (print .Lang “/”) -}}
{{- $.Scratch.Add “pages” . -}}
{{- end -}}
{{- end -}}
{{- $.Scratch.Set “lastmod” “” -}}

{{- range $.Scratch.Get “pages” -}}

{{ .Permalink }}
{{ dateFormat “2006-01-02” .Lastmod }}

{{- $.Scratch.Set “lastmod” (print .Lastmod) -}}
{{- end -}}
{{- with $.Scratch.Get “lastmod” -}}
{{- if ne . “” -}}

{{ (print $.Site.BaseURL $curLang “sitemap.xml”) }}
{{ . }}

{{- end -}}
{{- end -}}

{{- end -}}

who can help to make code for all my sitemap files?

I put your sitemap through validator and they are all ok.
It is normal that /sitemap.xml will be rendered nicely by browser but /uk/sitemap.xml will look like plain text. The browsers applying templates to it and on sitemaps in subdirectories there is a problem.

The sitemap working.

This issue been discussed and diagnosed, potentially fixed, but then reverted to default (the default that is working) and left like that.

I would suggest ignoring the way how sitemap is displayed in browser and through it through Google Search Console or any other sitemap validator and as long they do not report any errors leave it as it is, as its working.

Once again, ignore the way how they are displayed in Browser. only 0.01% of humans will read this file this way.

1 Like

this pages is not valid. Who know how to make a valid pages? I dont know why, but i think its one of the several variants i have only 33 pages in index, I have about 300 pages in total.

i check it when put in google this:

Help please to make a correct sitemap files

There is one thing that you misunderstand saying that sitemap is not valid.

If you saying not valid everybody thinking about validating through validator. The validator show now issues.

Your problem is that not about validity of sitemap but about its content.

From what I understand you see less pages in sitemap than it shall be.

The second part, where you saying that google indexed only a few pages from all submitted is nothing to do with sitemap. You can submit million pages through sitemap to GSC but that doesn’t mean that all pages will be indexed. This is why in GSC there is report showing indexed and no-indexed pages.

My suggestion is,
head to GSC and submit your above sitemaps than provide screenshot with numbers how many there is Discovered pages per sitemap. Then advise where the numbers in your opinion are wrong.

FYI, I will paste you mine files from \layouts\_default\ that you can try

for sitemapindex.xml

{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<sitemapindex xmlns="">
  {{ range . }}
    <loc>{{ .SitemapAbsURL }}</loc>
    {{ if not .LastChange.IsZero }}
      <lastmod>{{ .LastChange.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</lastmod>
    {{ end }}
  {{ end }}

For sitemap.xml

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

Try with this files and see if you got different numbers in GSC.