Skip to content

Commit

Permalink
feat: sitemap and robots noindex
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipe Carneiro committed Jan 11, 2024
1 parent fa6e52c commit c658cd9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions exampleSite/content/post/bootstrap-5-2-0-beta/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ categories: ["The Bootstrap Blog"]
tags: ["Bootstrap"]
keywords: ["bootstrap 5 2 0 beta","bootstrap 5","bootstrap"]
authors: ["Mark Otto"]
noindex: true
---

![Bootstrap 5 2 0 Beta](bootstrap-5-2-0-beta.png)
Expand Down
24 changes: 24 additions & 0 deletions layouts/_default/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{ 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 .Data.Pages }}
{{- if and (.Permalink) (not .Params.noindex) -}}
<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 }}
</urlset>
2 changes: 1 addition & 1 deletion layouts/partials/head/seo.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{ end -}}
{{ end -}}

{{ if eq .Kind "404" }}
{{ if or (.Params.noindex) (eq .Kind "404") }}
<meta name="robots" content="noindex">
{{ end }}

Expand Down

0 comments on commit c658cd9

Please sign in to comment.