diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go
index d8f10df83..5f536ecf2 100644
--- a/hugolib/sitemap_test.go
+++ b/hugolib/sitemap_test.go
@@ -80,8 +80,8 @@ Doc2
b := Test(t, files)
b.AssertFileContent("public/sitemap.xml", "https://example.com/en/sitemap.xml", "https://example.com/nn/sitemap.xml")
- b.AssertFileContent("public/en/sitemap.xml", " https://example.com/sect/doc1/", "doc2")
- b.AssertFileContent("public/nn/sitemap.xml", " https://example.com/nn/sect/doc2/")
+ b.AssertFileContent("public/en/sitemap.xml", " https://example.com/sect/doc1/", "doc2", `hreflang="en"`, `hreflang="nn"`)
+ b.AssertFileContent("public/nn/sitemap.xml", " https://example.com/nn/sect/doc2/", `hreflang="en"`, `hreflang="nn"`)
}
// https://github.com/gohugoio/hugo/issues/5910
diff --git a/tpl/tplimpl/embedded/templates/sitemap.xml b/tpl/tplimpl/embedded/templates/sitemap.xml
index d3539b190..bdedcacb1 100644
--- a/tpl/tplimpl/embedded/templates/sitemap.xml
+++ b/tpl/tplimpl/embedded/templates/sitemap.xml
@@ -8,17 +8,12 @@
{{ .Permalink }}{{ if not .Lastmod.IsZero }}
{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }}{{ with .Sitemap.ChangeFreq }}
{{ . }}{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
- {{ .Sitemap.Priority }}{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
+ {{ .Sitemap.Priority }}{{ end }}{{ $allTranslations := .AllTranslations }}{{ if gt ($allTranslations | len) 1 }}{{ range $allTranslations }}
{{ end }}
- {{ end }}
+ />{{ end }}{{ end }}
{{- end -}}
{{ end }}