From 1283f3d31243d1ac63ce718c4039ba6b85f5d721 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Thu, 2 Jun 2022 23:41:46 +0200 Subject: Provide ability to hide particular page from the sitemap --- CHANGELOG.md | 2 ++ layouts/_default/sitemap.xml | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 layouts/_default/sitemap.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c9da82..cf92297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Provide ability to include custom scripts in the theme - Provide ability to specify custom language of a post - Add tagging support +- Provide ability to hide particular page from the sitemap by using + `private: true` in front matter ### Changed diff --git a/layouts/_default/sitemap.xml b/layouts/_default/sitemap.xml new file mode 100644 index 0000000..3745dc5 --- /dev/null +++ b/layouts/_default/sitemap.xml @@ -0,0 +1,24 @@ +{{- $dateFormat := site.Params.dateFormatFeed | default "2006-01-02T15:04:05-07:00" -}} + +{{- printf "" | safeHTML }} + + {{ range .Data.Pages }}{{ if ne .Params.private true }} + + {{ .Permalink }}{{ if not .Lastmod.IsZero }} + {{ safeHTML ( .Lastmod.Format $dateFormat | html ) }}{{ end }}{{ with .Sitemap.ChangeFreq }} + {{ . }}{{ end }}{{ if ge .Sitemap.Priority 0.0 }} + {{ .Sitemap.Priority }}{{ end }}{{ if .IsTranslated }}{{ range .Translations }} + {{ end }} + {{ end }} + + {{ end }}{{ end }} + -- cgit v1.2.3