From d12bd8b06961fbb8491353c57243f5e122fa702b Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 11 Sep 2022 13:54:25 +0200 Subject: [PATCH] feat: add new option geekblogSeoIgnore (#307) --- .drone.yml | 4 +-- exampleSite/{ => config/_default}/config.yaml | 18 ---------- exampleSite/config/_default/params.yaml | 17 ++++++++++ exampleSite/config/ci/params.yaml | 4 +++ .../content/posts/advanced/includes.md | 2 +- .../content/posts/usage/configuration.md | 10 ++++++ layouts/404.html | 7 ---- layouts/_default/sitemap.xml | 34 +++++++++++++++++++ layouts/partials/head/meta.html | 7 +++- layouts/robots.txt | 1 - 10 files changed, 74 insertions(+), 30 deletions(-) rename exampleSite/{ => config/_default}/config.yaml (71%) create mode 100644 exampleSite/config/_default/params.yaml create mode 100644 exampleSite/config/ci/params.yaml create mode 100644 layouts/_default/sitemap.xml diff --git a/.drone.yml b/.drone.yml index d662978..7277aeb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 similarity index 71% rename from exampleSite/config.yaml rename to 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: -{{< 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" >}} 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 " 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 " 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 @@ {{ partial "head/meta" . }} Lost? Don't worry - {{ partial "head/favicons" . }} {{ partial "head/others" . }} {{ partial "svg-sprites" . }} - -
{{ partial "site-header" . }} - -
@@ -31,9 +26,7 @@
- {{ partial "site-footer" . }} -
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 "" | safeHTML }} + + {{- $seoIgnore := default (slice "taxonomy" "section" "term" "404") .Site.Params.GeekblogSeoIgnore -}} + {{- range .Data.Pages }} + {{- if and .Permalink (not (in $seoIgnore .Kind)) }} + + {{ .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/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) }} + +{{- else }} + +{{- end }} {{- with partial "utils/description" . }} {{- end }} @@ -20,7 +26,6 @@ {{- $list = $list | append $author.name -}} {{- end }} {{- end }} - {{- with $list }} {{- 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 }}