From c51db49cdd6c754950cda527e0e4e5c683dc075e Mon Sep 17 00:00:00 2001 From: Ian Maddaus Date: Fri, 15 Nov 2024 16:51:26 -0500 Subject: [PATCH] Im/sitemap (#4332) * WIP Signed-off-by: Ian Maddaus * Additional sitemap-main layout updates Signed-off-by: Ian Maddaus * Update main sitemap layout Signed-off-by: Ian Maddaus * Update sitemaps param Signed-off-by: Ian Maddaus --------- Signed-off-by: Ian Maddaus --- config/_default/params.toml | 11 ++++++++++ generated/config.toml | 2 +- hugo.toml | 30 +++++++++++++++++--------- layouts/_default/home.sitemap-main.xml | 26 ++++++++++++++++++++++ layouts/_default/sitemap.xml | 11 ++++++++++ 5 files changed, 69 insertions(+), 11 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..9de84db6dd 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -17,9 +17,20 @@ menuOrder = [ "legacy", "extra" ] + 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" +] + [chef-web-docs] gh_path = "https://github.com/chef/chef-web-docs/blob/main/content/" 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/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..fe3ec2fa14 --- /dev/null +++ b/layouts/_default/home.sitemap-main.xml @@ -0,0 +1,26 @@ +{{ printf "" | safeHTML }} + +{{ 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 }} + + + diff --git a/layouts/_default/sitemap.xml b/layouts/_default/sitemap.xml new file mode 100644 index 0000000000..f7beb7f9b3 --- /dev/null +++ b/layouts/_default/sitemap.xml @@ -0,0 +1,11 @@ +{{ printf "" | safeHTML }} + +{{- range .Site.Params.sitemaps }} + + {{ . }} + +{{ end -}} + + + +