From d1c3cef7b292e0070ee90922e65dbc4aff48062f Mon Sep 17 00:00:00 2001 From: Ian Maddaus Date: Fri, 15 Nov 2024 12:09:52 -0500 Subject: [PATCH] Update main sitemap layout Signed-off-by: Ian Maddaus --- config/_default/params.toml | 5 +++ generated/config.toml | 2 +- layouts/_default/home.sitemap-main.xml | 45 +++++++++++++------------- layouts/_default/sitemap.xml | 3 ++ 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index 5057b4459d..876d62b57c 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -21,6 +21,11 @@ menuOrder = [ enable_search = true robots = '' +# sitemaps lists sitemaps that are indexed by the main sitemap layout. +# see: +# - layouts/_default/sitemap.xml +# - layouts/_default/home.sitemap-main.xml + sitemaps = [ "https://docs.chef.io/sitemap-main.xml", "https://docs.chef.io/360/1.0/sitemap.xml", diff --git a/generated/config.toml b/generated/config.toml index 7cf27fce75..6dd827c86f 100644 --- a/generated/config.toml +++ b/generated/config.toml @@ -1,6 +1,6 @@ ## Config file for generated dir. -disableKinds = [ "sitemap", "taxonomy", "term", "RSS", "sitemap"] +disableKinds = [ "sitemap", "taxonomy", "term", "RSS"] publishDir = "generated_content" [module] diff --git a/layouts/_default/home.sitemap-main.xml b/layouts/_default/home.sitemap-main.xml index e1a4f42e52..fe3ec2fa14 100644 --- a/layouts/_default/home.sitemap-main.xml +++ b/layouts/_default/home.sitemap-main.xml @@ -1,25 +1,26 @@ -{{ printf "" | safeHTML }} +{{ printf "" | safeHTML }} - {{ range where .Pages "Sitemap.Disable" "ne" true }} - {{- if .Permalink -}} - - {{ .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 -}} - {{ end }} +{{ range .Site.Pages }} + {{- if or (eq (isset .Params "sitemapexclude") false) (ne .Params.sitemapExclude 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 }} +{{ end }} - \ No newline at end of file + + diff --git a/layouts/_default/sitemap.xml b/layouts/_default/sitemap.xml index d3b0f73c4c..f7beb7f9b3 100644 --- a/layouts/_default/sitemap.xml +++ b/layouts/_default/sitemap.xml @@ -6,3 +6,6 @@ {{ end -}} + + +