From c7616ab56818f76b3aeef318f8a46a011df5ec3a Mon Sep 17 00:00:00 2001 From: James Tatum Date: Mon, 20 Sep 2021 11:20:57 -0700 Subject: [PATCH] feat: don't index private pages (#2464) Setting the private attribute on pages currently prevents them from showing up in Wowchemy search. This change instructs search engines to also ignore pages set to private. Fixes #2444 --- wowchemy/layouts/_default/sitemap.xml | 30 ++++++++++++++++++++++++ wowchemy/layouts/partials/site_head.html | 4 ++++ 2 files changed, 34 insertions(+) create mode 100644 wowchemy/layouts/_default/sitemap.xml diff --git a/wowchemy/layouts/_default/sitemap.xml b/wowchemy/layouts/_default/sitemap.xml new file mode 100644 index 00000000..b5761c61 --- /dev/null +++ b/wowchemy/layouts/_default/sitemap.xml @@ -0,0 +1,30 @@ +{{ printf "" | safeHTML }} + + {{/* Check that page is built (has a URL) and is not private. */}} + {{ range where (where .Data.Pages "Permalink" "!=" nil) "Params.private" "ne" true }} + + {{ .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 -}} + + {{- end -}} + + + + {{- end -}} + + {{- end -}} + diff --git a/wowchemy/layouts/partials/site_head.html b/wowchemy/layouts/partials/site_head.html index f937367a..03380828 100644 --- a/wowchemy/layouts/partials/site_head.html +++ b/wowchemy/layouts/partials/site_head.html @@ -8,6 +8,10 @@ {{ end }} + {{ if .Params.private }} + + {{- end -}} + {{ if site.Params.marketing.google_optimize | and hugo.IsProduction }} {{- end -}}