From ba6bebb05e52a4905a3f8d919dea6f63da374008 Mon Sep 17 00:00:00 2001 From: Ian Maddaus Date: Fri, 15 Nov 2024 09:46:38 -0500 Subject: [PATCH 1/4] WIP Signed-off-by: Ian Maddaus --- config/_default/params.toml | 7 ++++++ hugo.toml | 30 +++++++++++++++++--------- layouts/_default/home.sitemap-main.xml | 26 ++++++++++++++++++++++ layouts/_default/sitemap.xml | 8 +++++++ 4 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 layouts/_default/home.sitemap-main.xml create mode 100644 layouts/_default/sitemap.xml diff --git a/config/_default/params.toml b/config/_default/params.toml index 39dde6df6a..5057b4459d 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -17,9 +17,16 @@ menuOrder = [ "legacy", "extra" ] + enable_search = true robots = '' +sitemaps = [ + "https://docs.chef.io/sitemap-main.xml", + "https://docs.chef.io/360/1.0/sitemap.xml", + "https://docs.chef.io/360/1.1/sitemap.xml" +] + [chef-web-docs] gh_path = "https://github.com/chef/chef-web-docs/blob/main/content/" diff --git a/hugo.toml b/hugo.toml index 13b3eaefa7..9490e7eb96 100644 --- a/hugo.toml +++ b/hugo.toml @@ -7,24 +7,34 @@ pluralizeListTitles = false disableKinds = ["taxonomy", "term"] configDir = "config" -# We do redirects using Netlify's _redirects file, generated by Hugo (see "outputs" below). disableAliases = true # Summary length summaryLength = 20 + +# We do redirects using Netlify's _redirects file, generated by Hugo. +# See the REDIR output and output format and the text/netlify mediatype. [outputs] -home = [ "HTML", "RSS", "REDIR" ] -section = [ "HTML", "RSS" ] + home = [ "HTML", "RSS", "REDIR", "SITEMAP-MAIN" ] + section = [ "HTML", "RSS" ] [mediaTypes] -[mediaTypes."text/netlify"] -delimiter = "" + [mediaTypes."text/netlify"] + delimiter = "" [outputFormats] -[outputFormats.REDIR] -mediatype = "text/netlify" -baseName = "_redirects" -isPlainText = true -notAlternative = true + [outputFormats.REDIR] + mediatype = "text/netlify" + baseName = "_redirects" + isPlainText = true + notAlternative = true + + [outputFormats.SITEMAP-MAIN] + MediaType = "application/xml" + BaseName = "sitemap-main" + IsHTML = false + IsPlainText = true + Rel = "sitemap" + protocol = "xml://" [markup] [markup.goldmark] diff --git a/layouts/_default/home.sitemap-main.xml b/layouts/_default/home.sitemap-main.xml new file mode 100644 index 0000000000..f1875c9a13 --- /dev/null +++ b/layouts/_default/home.sitemap-main.xml @@ -0,0 +1,26 @@ +{{ printf "" | safeHTML }} + +{{ range .Data.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 new file mode 100644 index 0000000000..d3b0f73c4c --- /dev/null +++ b/layouts/_default/sitemap.xml @@ -0,0 +1,8 @@ +{{ printf "" | safeHTML }} + +{{- range .Site.Params.sitemaps }} + + {{ . }} + +{{ end -}} + From 5796d17103e5cf7144aaf7bbc1b3888c0039e302 Mon Sep 17 00:00:00 2001 From: Ian Maddaus Date: Fri, 15 Nov 2024 10:06:01 -0500 Subject: [PATCH 2/4] Additional sitemap-main layout updates Signed-off-by: Ian Maddaus --- layouts/_default/home.sitemap-main.xml | 45 +++++++++++++------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/layouts/_default/home.sitemap-main.xml b/layouts/_default/home.sitemap-main.xml index f1875c9a13..e1a4f42e52 100644 --- a/layouts/_default/home.sitemap-main.xml +++ b/layouts/_default/home.sitemap-main.xml @@ -1,26 +1,25 @@ -{{ printf "" | safeHTML }} +{{ printf "" | safeHTML }} -{{ range .Data.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 }} + {{ 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 }} - - \ No newline at end of file + \ No newline at end of file From d1c3cef7b292e0070ee90922e65dbc4aff48062f Mon Sep 17 00:00:00 2001 From: Ian Maddaus Date: Fri, 15 Nov 2024 12:09:52 -0500 Subject: [PATCH 3/4] 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 -}} + + + From 53b13db6df8cd6bdbdfdaa2ab9cb4ac683424c86 Mon Sep 17 00:00:00 2001 From: Ian Maddaus Date: Fri, 15 Nov 2024 16:45:09 -0500 Subject: [PATCH 4/4] Update sitemaps param Signed-off-by: Ian Maddaus --- config/_default/params.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index 876d62b57c..9de84db6dd 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -28,8 +28,7 @@ robots = '' sitemaps = [ "https://docs.chef.io/sitemap-main.xml", - "https://docs.chef.io/360/1.0/sitemap.xml", - "https://docs.chef.io/360/1.1/sitemap.xml" + "https://docs.chef.io/360/1.0/sitemap.xml" ] [chef-web-docs]