mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-01-23 06:55:43 -06:00
Merge pull request #1015 from fuse314/feature/exclude_external_from_sitemap
feat: exclude external pages from Sitemap
This commit is contained in:
commit
228ee0b005
1 changed files with 19 additions and 24 deletions
|
@ -1,28 +1,23 @@
|
||||||
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
|
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
|
||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
||||||
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
||||||
{{ range .Data.Pages }}
|
{{ range .Data.Pages }}{{ if not (in .Site.Params.sitemap.excludedKinds .Kind) }}{{ if and (.Param "xml" | default true) (or (not .Params.externalUrl) (and (.Params.externalUrl) (and (not (hasPrefix .Params.externalUrl "http://")) (not (hasPrefix .Params.externalUrl "https://"))))) }}
|
||||||
{{ if not (in .Site.Params.sitemap.excludedKinds .Kind) }}
|
{{- if .Permalink -}}{{ $link := .Permalink }}{{ if .Params.externalUrl }}{{ $link = printf "%s%s" .Site.BaseURL (substr .Params.externalUrl 1) }}{{ end }}
|
||||||
{{ if and (.Param "xml" | default true) (not (isset .Params "externalUrl")) }}
|
<url>
|
||||||
{{- if .Permalink -}}
|
<loc>{{ $link }}</loc>{{ if not .Lastmod.IsZero }}
|
||||||
<url>
|
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
|
||||||
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
|
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
|
||||||
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
|
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
|
||||||
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
|
<xhtml:link
|
||||||
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
|
rel="alternate"
|
||||||
<xhtml:link
|
hreflang="{{ .Language.LanguageCode }}"
|
||||||
rel="alternate"
|
href="{{ .Permalink }}"
|
||||||
hreflang="{{ .Language.Lang }}"
|
/>{{ end }}
|
||||||
href="{{ .Permalink }}"
|
<xhtml:link
|
||||||
/>{{ end }}
|
rel="alternate"
|
||||||
<xhtml:link
|
hreflang="{{ .Language.LanguageCode }}"
|
||||||
rel="alternate"
|
href="{{ $link }}"
|
||||||
hreflang="{{ .Language.Lang }}"
|
/>{{ end }}
|
||||||
href="{{ .Permalink }}"
|
</url>
|
||||||
/>{{ end }}
|
{{- end -}}{{ end }}{{ end }}{{ end }}
|
||||||
</url>
|
|
||||||
{{- end -}}
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
</urlset>
|
</urlset>
|
||||||
|
|
Loading…
Reference in a new issue