add meta elements and fix title

This commit is contained in:
Robert Kaussow 2020-07-22 10:51:13 +02:00
parent ffbb01c288
commit 1cb88d9e6c
Signed by: xoxys
GPG Key ID: 65362AE74AF98B61
5 changed files with 49 additions and 6 deletions

View File

@ -1 +1,5 @@
- initial release
- ENHANCEMENT
- allow setting some common meta elements e.g. description and authors
- prevent duplicate title on the start page
- BUGFIX
- dont display duplicate title on home page

View File

@ -128,6 +128,14 @@ enableGitInfo = true
[geekblogContentLicense]
name = "CC BY-SA 4.0"
link = "https://creativecommons.org/licenses/by-sa/4.0/"
# (Optional, default none) Default meta description used for the start page and as a fallback for
# every site without an own description.
geekblogDescription = "This is my personal blog about tech."
# (Optional, default none) Default meta keywords used for the start page and as a fallback for
# every site without own keywords. Note: Meta keywords seems to be ignored by most modern search engines.
geekblogKeywords =
```
{{< /tab >}}
@ -231,6 +239,14 @@ params:
geekblogContentLicense:
name: CC BY-SA 4.0
link: https://creativecommons.org/licenses/by-sa/4.0/
# (Optional, default none) Default meta description used for the start page and as a fallback for
# every site without an own description.
geekblogDescription: "This is my personal blog about tech."
# (Optional, default none) Default meta keywords used for the start page and as a fallback for
# every site without own keywords. Note: Meta keywords seems to be ignored by most modern search engines.
geekblogKeywords: []
```
{{< /tab >}}

View File

@ -3,6 +3,7 @@ title: "Post with image"
date: 2020-06-22T20:00:00+02:00
authors:
- richard-roe
- john-doe
tags:
- Open Source
- Development

View File

@ -1,8 +1,26 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="{{ partial "title" . }}">
{{ $description := default .Site.Params.GeekblogDescription (default .Summary .Description) }}
{{ $keywords := default .Site.Params.GeekblogKeywords .Keywords }}
{{ $author := default (slice .Site.Params.GeekblogAuthor) .Params.authors }}
{{ with $description }}
<meta name="description" content="{{ . }}">
{{ end }}
{{ with $keywords }}
<meta name="keywords" content="{{ delimit . "," }}">
{{ end }}
{{ with $author }}
{{ $authors := slice }}
{{ range sort . }}
{{ $author := index $.Site.Data.authors . }}
{{ $authors = $authors | append $author.name }}
{{ end }}
<title>{{ partial "title" . }} | {{ .Site.Title -}}</title>
{{ with $authors }}
<meta name="author" content="{{ delimit . "," }}">
{{ end }}
{{ end }}
<title>{{ if not (eq .Kind "home") }}{{ partial "title" . }} | {{ end }}{{ .Site.Title -}}</title>
<link rel="icon" href="{{ "favicon/favicon-32x32.png" | relURL }}" type="image/x-icon">
<link rel="stylesheet" href="{{ "main.min.css" | relURL }}" media="screen">

View File

@ -1,11 +1,15 @@
{{ $title := "" }}
{{ if .Title }}
{{ $title = .Title }}
{{ $title = .Title }}
{{ else if and .IsSection .File }}
{{ $title = path.Base .File.Dir | humanize | title }}
{{ $title = path.Base .File.Dir | humanize | title }}
{{ else if and .IsPage .File }}
{{ $title = .File.BaseFileName | humanize | title }}
{{ $title = .File.BaseFileName | humanize | title }}
{{ end }}
{{ if eq .Kind "term" }}
{{ $title = $title | humanize | title }}
{{ end }}
{{ return $title }}