Skip to content

Commit daf525d

Browse files
committed
sitemap: adjust to Hugo's build-in code #824
1 parent c69541e commit daf525d

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

layouts/_default/sitemap.xml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
{{- partialCached "page-meta.hugo" . .RelPermalink }}
22
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
33
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
4-
{{- range .Data.Pages }}
4+
{{- range where .Pages "Sitemap.Disable" "ne" true }}
55
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
66
<url>
7-
<loc>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</loc>
8-
{{- if not .Lastmod.IsZero }}
9-
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>
10-
{{- end }}
11-
{{- with .Sitemap.ChangeFreq }}
12-
<changefreq>{{ . }}</changefreq>
13-
{{- end }}
14-
{{- if ge .Sitemap.Priority 0.0 }}
15-
<priority>{{ .Sitemap.Priority }}</priority>
16-
{{- end }}
17-
{{- if .IsTranslated }}
18-
{{- range $index, $trans := .AllTranslations }}
19-
{{- if eq $index 0 }}
20-
<xhtml:link rel="alternate" hreflang="x-default" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}" />
21-
{{- end }}
22-
<xhtml:link rel="alternate" hreflang="{{ .Language.LanguageCode }}" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}" />
23-
{{- end }}
24-
{{- end }}
7+
<loc>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</loc>{{ if not .Lastmod.IsZero }}
8+
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
9+
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
10+
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range $index, $trans := .AllTranslations }}{{- if eq $index 0 }}
11+
<xhtml:link rel="alternate" hreflang="x-default" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}" />{{ end }}
12+
<xhtml:link rel="alternate" hreflang="{{ .Language.LanguageCode }}" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}" />{{ end }}{{ end }}
2513
</url>
2614
{{- end -}}
2715
{{- end }}

0 commit comments

Comments
 (0)