feat: add new option geekblogSeoIgnore (#307)

This commit is contained in:
Robert Kaussow 2022-09-11 13:54:25 +02:00 committed by GitHub
parent c95851d0a6
commit d12bd8b069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 74 additions and 30 deletions

View File

@ -29,7 +29,7 @@ steps:
image: thegeeklab/hugo:0.97.3 image: thegeeklab/hugo:0.97.3
commands: commands:
- mkdir -p exampleSite/themes/ && ln -s $(pwd)/ exampleSite/themes/hugo-geekblog - 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 - name: html-validation
image: thegeeklab/vnu image: thegeeklab/vnu
@ -287,6 +287,6 @@ depends_on:
--- ---
kind: signature kind: signature
hmac: a3c1af6ac4b291e8aa1e7f9cbccb1a7c7edbf75163a36ed811c0694227a4f792 hmac: f04800844c631b0c9e17b7a7c015ca971754516f609248a380ee0db2ec2037c7
... ...

View File

@ -69,24 +69,6 @@ outputs:
enableRobotsTXT: true 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: security:
exec: exec:
allow: allow:

View File

@ -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

View File

@ -0,0 +1,4 @@
---
geekblogSeoIgnore:
- "taxonomy"
- "term"

View File

@ -64,7 +64,7 @@ Result:
<!-- prettier-ignore-start --> <!-- prettier-ignore-start -->
<!-- spellchecker-disable --> <!-- 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 --> <!-- spellchecker-enable -->
<!-- prettier-ignore-end --> <!-- prettier-ignore-end -->

View File

@ -127,6 +127,10 @@ enableRobotsTXT = true
# (Optional, default true) Display a "Back to top" link in the site footer. # (Optional, default true) Display a "Back to top" link in the site footer.
geekblogBackToTop = true 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. # (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. # Could be used if you want to give credits to your hosting provider.
[params.geekblogHostedOn] [params.geekblogHostedOn]
@ -259,6 +263,12 @@ params:
# (Optional, default true) Display a "Back to top" link in the site footer. # (Optional, default true) Display a "Back to top" link in the site footer.
geekblogBackToTop: true 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. # (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. # Could be used if you want to give credits to your hosting provider.
geekblogHostedOn: geekblogHostedOn:

View File

@ -3,19 +3,14 @@
<head> <head>
{{ partial "head/meta" . }} {{ partial "head/meta" . }}
<title>Lost? Don't worry</title> <title>Lost? Don't worry</title>
{{ partial "head/favicons" . }} {{ partial "head/favicons" . }}
{{ partial "head/others" . }} {{ partial "head/others" . }}
</head> </head>
<body> <body>
{{ partial "svg-sprites" . }} {{ partial "svg-sprites" . }}
<div class="wrapper"> <div class="wrapper">
{{ partial "site-header" . }} {{ partial "site-header" . }}
<main class="gblog-error flex-even"> <main class="gblog-error flex-even">
<div class="flex align-center justify-center"> <div class="flex align-center justify-center">
<div class="gblog-error__icon"> <div class="gblog-error__icon">
@ -31,9 +26,7 @@
</div> </div>
</div> </div>
</main> </main>
{{ partial "site-footer" . }} {{ partial "site-footer" . }}
</div> </div>
</body> </body>
</html> </html>

View File

@ -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>

View File

@ -5,7 +5,13 @@
{{- $keywords := default .Site.Params.Keywords .Keywords -}} {{- $keywords := default .Site.Params.Keywords .Keywords -}}
{{- $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors -}} {{- $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" . }} {{- with partial "utils/description" . }}
<meta name="description" content="{{ . | plainify | htmlUnescape | chomp }}" /> <meta name="description" content="{{ . | plainify | htmlUnescape | chomp }}" />
{{- end }} {{- end }}
@ -20,7 +26,6 @@
{{- $list = $list | append $author.name -}} {{- $list = $list | append $author.name -}}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- with $list }} {{- with $list }}
<meta name="author" content="{{ delimit . "," }}" /> <meta name="author" content="{{ delimit . "," }}" />
{{- end }} {{- end }}

View File

@ -1,5 +1,4 @@
User-agent: * User-agent: *
Disallow: /categories/* Disallow: /categories/*
Disallow: /tags/* Disallow: /tags/*
Sitemap: {{ "sitemap.xml" | absURL }} Sitemap: {{ "sitemap.xml" | absURL }}