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

View File

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

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

View File

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

View File

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

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 -}}
{{- $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 }}

View File

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