Skip to content

Commit

Permalink
Update main sitemap layout
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Maddaus <[email protected]>
  • Loading branch information
IanMadd committed Nov 15, 2024
1 parent 5796d17 commit d1c3cef
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
5 changes: 5 additions & 0 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion generated/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Config file for generated dir.

disableKinds = [ "sitemap", "taxonomy", "term", "RSS", "sitemap"]
disableKinds = [ "sitemap", "taxonomy", "term", "RSS"]
publishDir = "generated_content"

[module]
Expand Down
45 changes: 23 additions & 22 deletions layouts/_default/home.sitemap-main.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range where .Pages "Sitemap.Disable" "ne" true }}
{{- if .Permalink -}}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
<xhtml:link
rel="alternate"
hreflang="{{ .Language.LanguageCode }}"
href="{{ .Permalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Language.LanguageCode }}"
href="{{ .Permalink }}"
/>{{ end }}
</url>
{{- end -}}
{{ end }}
{{ range .Site.Pages }}
{{- if or (eq (isset .Params "sitemapexclude") false) (ne .Params.sitemapExclude true) }}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
<xhtml:link
rel="alternate"
hreflang="{{ .Language.Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Language.Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
</url>
{{- end }}
{{ end }}
</urlset>
<!-- hello -->

<!-- From https://dereckcurry.com/posts/excluding-pages-from-the-sitemap/ -->
3 changes: 3 additions & 0 deletions layouts/_default/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
</sitemap>
{{ end -}}
</sitemapindex>

<!-- https://developers.google.com/search/docs/crawling-indexing/sitemaps/large-sitemaps -->
<!-- https://swiftype.com/documentation/site-search/crawler-configuration/sitemap -->

0 comments on commit d1c3cef

Please sign in to comment.