Skip to content

Instantly share code, notes, and snippets.

@nfriedli
Created April 8, 2017 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfriedli/1d40763fc9d3d9d48fd0ae05c018f1e0 to your computer and use it in GitHub Desktop.
Save nfriedli/1d40763fc9d3d9d48fd0ae05c018f1e0 to your computer and use it in GitHub Desktop.
Multilingual sitemap.xml for GoHugo
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range .Data.Pages }}
<url>
<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 }}
<xhtml:link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}"/>
{{ range .Translations }}
<xhtml:link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}"/>
{{ end}}
{{ end }}
</url>
{{ end }}
</urlset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment