diff options
author | Robert Kaussow <mail@thegeeklab.de> | 2022-09-11 14:54:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-11 14:54:25 +0300 |
commit | d12bd8b06961fbb8491353c57243f5e122fa702b (patch) | |
tree | 98ea9b07c61286a6a18d629586131d44a5aa3446 | |
parent | c95851d0a6b86a1e1d172b648fe40726cffacbaf (diff) |
feat: add new option geekblogSeoIgnore (#307)v0.22.0
-rw-r--r-- | .drone.yml | 4 | ||||
-rw-r--r-- | exampleSite/config/_default/config.yaml (renamed from exampleSite/config.yaml) | 18 | ||||
-rw-r--r-- | exampleSite/config/_default/params.yaml | 17 | ||||
-rw-r--r-- | exampleSite/config/ci/params.yaml | 4 | ||||
-rw-r--r-- | exampleSite/content/posts/advanced/includes.md | 2 | ||||
-rw-r--r-- | exampleSite/content/posts/usage/configuration.md | 10 | ||||
-rw-r--r-- | layouts/404.html | 7 | ||||
-rw-r--r-- | layouts/_default/sitemap.xml | 34 | ||||
-rw-r--r-- | layouts/partials/head/meta.html | 7 | ||||
-rw-r--r-- | layouts/robots.txt | 1 |
10 files changed, 74 insertions, 30 deletions
@@ -29,7 +29,7 @@ steps: image: thegeeklab/hugo:0.97.3 commands: - mkdir -p exampleSite/themes/ && ln -s $(pwd)/ exampleSite/themes/hugo-geekblog - - hugo --panicOnWarning -s exampleSite/ -b http://localhost:8000/ + - hugo --panicOnWarning -s exampleSite/ -b http://localhost:8000/ -e ci - name: html-validation image: thegeeklab/vnu @@ -287,6 +287,6 @@ depends_on: --- kind: signature -hmac: a3c1af6ac4b291e8aa1e7f9cbccb1a7c7edbf75163a36ed811c0694227a4f792 +hmac: f04800844c631b0c9e17b7a7c015ca971754516f609248a380ee0db2ec2037c7 ... diff --git a/exampleSite/config.yaml b/exampleSite/config/_default/config.yaml index 4b334f6..9d5aaf1 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config/_default/config.yaml @@ -69,24 +69,6 @@ outputs: enableRobotsTXT: true -params: - subtitle: Subtitle to describe your blog - description: > - hugo-geekblog is a simple Hugo theme for personal blogs. This page is theme documentation - and powered by the latest version of hugo-geekblog itself. - images: - - "socialmedia2.png" - - geekblogToC: 3 - geekblogAuthor: john-doe - - geekblogLegalNotice: https://thegeeklab.de/legal-notice/#contact-information - geekblogPrivacyPolicy: https://thegeeklab.de/legal-notice/#privacy-policy - - geekblogImageLazyLoading: true - geekblogDarkModeDim: true - geekblogTagsToMenu: true - security: exec: allow: diff --git a/exampleSite/config/_default/params.yaml b/exampleSite/config/_default/params.yaml new file mode 100644 index 0000000..f3e4e03 --- /dev/null +++ b/exampleSite/config/_default/params.yaml @@ -0,0 +1,17 @@ +--- +subtitle: Subtitle to describe your blog +description: > + hugo-geekblog is a simple Hugo theme for personal blogs. This page is theme documentation + and powered by the latest version of hugo-geekblog itself. +images: + - "socialmedia2.png" + +geekblogToC: 3 +geekblogAuthor: john-doe + +geekblogLegalNotice: https://thegeeklab.de/legal-notice/#contact-information +geekblogPrivacyPolicy: https://thegeeklab.de/legal-notice/#privacy-policy + +geekblogImageLazyLoading: true +geekblogDarkModeDim: true +geekblogTagsToMenu: true diff --git a/exampleSite/config/ci/params.yaml b/exampleSite/config/ci/params.yaml new file mode 100644 index 0000000..f7e22e6 --- /dev/null +++ b/exampleSite/config/ci/params.yaml @@ -0,0 +1,4 @@ +--- +geekblogSeoIgnore: + - "taxonomy" + - "term" diff --git a/exampleSite/content/posts/advanced/includes.md b/exampleSite/content/posts/advanced/includes.md index 1be4d38..f2d19df 100644 --- a/exampleSite/content/posts/advanced/includes.md +++ b/exampleSite/content/posts/advanced/includes.md @@ -64,7 +64,7 @@ Result: <!-- prettier-ignore-start --> <!-- spellchecker-disable --> -{{< include file="config.yaml" language="yaml" options="linenos=table,hl_lines=5-6,linenostart=100" >}} +{{< include file="config/_default/config.yaml" language="yaml" options="linenos=table,hl_lines=5-6,linenostart=100" >}} <!-- spellchecker-enable --> <!-- prettier-ignore-end --> diff --git a/exampleSite/content/posts/usage/configuration.md b/exampleSite/content/posts/usage/configuration.md index 6d0f173..82577d6 100644 --- a/exampleSite/content/posts/usage/configuration.md +++ b/exampleSite/content/posts/usage/configuration.md @@ -127,6 +127,10 @@ enableRobotsTXT = true # (Optional, default true) Display a "Back to top" link in the site footer. geekblogBackToTop = true + # (Optional, default ["taxonomy", "section", "term", "404"]) + # Page types to exclude from the sitemap and set to noindex,nofollow. + geekblogSeoIgnore = ["taxonomy", "section"] + # (Optional, default none) Adds a "Hosted on <provider>" line to the footer. # Could be used if you want to give credits to your hosting provider. [params.geekblogHostedOn] @@ -259,6 +263,12 @@ params: # (Optional, default true) Display a "Back to top" link in the site footer. geekblogBackToTop: true + # (Optional, default ["taxonomy", "section", "term", "404"]) + # Page types to exclude from the sitemap and set to noindex,nofollow. + geekblogSeoIgnore: + - "taxonomy" + - "section" + # (Optional, default none) Adds a "Hosted on <provider>" line to the footer. # Could be used if you want to give credits to your hosting provider. geekblogHostedOn: diff --git a/layouts/404.html b/layouts/404.html index d3b6d48..75205ab 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -3,19 +3,14 @@ <head> {{ partial "head/meta" . }} <title>Lost? Don't worry</title> - {{ partial "head/favicons" . }} {{ partial "head/others" . }} </head> <body> {{ partial "svg-sprites" . }} - - <div class="wrapper"> {{ partial "site-header" . }} - - <main class="gblog-error flex-even"> <div class="flex align-center justify-center"> <div class="gblog-error__icon"> @@ -31,9 +26,7 @@ </div> </div> </main> - {{ partial "site-footer" . }} - </div> </body> </html> diff --git a/layouts/_default/sitemap.xml b/layouts/_default/sitemap.xml new file mode 100644 index 0000000..51463bb --- /dev/null +++ b/layouts/_default/sitemap.xml @@ -0,0 +1,34 @@ +{{ 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"> + {{- $seoIgnore := default (slice "taxonomy" "section" "term" "404") .Site.Params.GeekblogSeoIgnore -}} + {{- range .Data.Pages }} + {{- if and .Permalink (not (in $seoIgnore .Kind)) }} + <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> diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html index 059cfc0..803b7dd 100644 --- a/layouts/partials/head/meta.html +++ b/layouts/partials/head/meta.html @@ -5,7 +5,13 @@ {{- $keywords := default .Site.Params.Keywords .Keywords -}} {{- $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors -}} +{{- $seoIgnore := default (slice "taxonomy" "section" "term" "404") .Site.Params.GeekblogSeoIgnore -}} +{{- if not (in $seoIgnore .Kind) }} + <meta name="robots" content="index, follow" /> +{{- else }} + <meta name="robots" content="noindex, nofollow" /> +{{- end }} {{- with partial "utils/description" . }} <meta name="description" content="{{ . | plainify | htmlUnescape | chomp }}" /> {{- end }} @@ -20,7 +26,6 @@ {{- $list = $list | append $author.name -}} {{- end }} {{- end }} - {{- with $list }} <meta name="author" content="{{ delimit . "," }}" /> {{- end }} diff --git a/layouts/robots.txt b/layouts/robots.txt index a96e147..4168a43 100644 --- a/layouts/robots.txt +++ b/layouts/robots.txt @@ -1,5 +1,4 @@ User-agent: * Disallow: /categories/* Disallow: /tags/* - Sitemap: {{ "sitemap.xml" | absURL }} |