From 07f124360d571b92827a1c131784e73a6a032505 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Fri, 24 Jul 2020 22:25:04 +0200 Subject: [PATCH] add json-ld structured data partial --- CHANGELOG.md | 6 ++- exampleSite/config.yml | 6 +-- exampleSite/content/posts/how-to-use.md | 18 ++++--- layouts/_default/baseof.html | 1 + layouts/_default/list.atom.xml | 2 +- layouts/partials/head/meta.html | 2 +- layouts/partials/head/microformats.html | 1 - layouts/partials/head/schema.html | 69 +++++++++++++++++++++++++ layouts/partials/site-header.html | 4 +- 9 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 layouts/partials/head/schema.html diff --git a/CHANGELOG.md b/CHANGELOG.md index ee5135a..96887a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,6 @@ +- BREAKING + - rename description and keyword variables + - rename logo variable + - rename subtitle variable - ENHANCEMENT - - move description and keyword variables + - add partial for json-ld structured data diff --git a/exampleSite/config.yml b/exampleSite/config.yml index 8da5e4c..071e5ca 100644 --- a/exampleSite/config.yml +++ b/exampleSite/config.yml @@ -54,13 +54,13 @@ outputs: enableRobotsTXT: true params: - images: - - "favicon/android-chrome-512x512.png" + 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: + - "favicon/android-chrome-512x512.png" - geekblogSubtitle: Subtitle to describe your blog geekblogToC: 3 geekblogAuthor: john-doe diff --git a/exampleSite/content/posts/how-to-use.md b/exampleSite/content/posts/how-to-use.md index 481a765..9a42809 100644 --- a/exampleSite/content/posts/how-to-use.md +++ b/exampleSite/content/posts/how-to-use.md @@ -88,19 +88,20 @@ enableGitInfo = true term = ["HTML", "ATOM"] [params] + subtitle = description = "This is my personal blog about tech." keywords = [] images = [] + # (Optional, default static/brand.svg) Set the path to a logo for the Geekblog + # relative to your 'static/' folder. + logo = logo.png + # (Optional, default 6) Set how many table of contents levels to be showed on page. # Use false to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/) # You can also specify this parameter per page in front matter. geekblogToC = 3 - # (Optional, default static/brand.svg) Set the path to a logo for the Geekblog - # relative to your 'static/' folder. - geekblogLogo = logo.png - # (Optional, default none) Add a link to your Legal Notice page to the site footer. # It can be either a remote url or a local file path relative to your content directory. geekblogLegalNotice = "https://blog.example.com/legal" @@ -198,19 +199,20 @@ outputs: enableRobotsTXT: true params: + subtitle: description: "This is my personal blog about tech." keywords: [] images: [] + # (Optional, default static/brand.svg) Set the path to a logo for the Geekblog + # relative to your 'static/' folder. + logo: logo.png + # (Optional, default 6) Set how many table of contents levels to be showed on page. # Use false to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/) # You can also specify this parameter per page in front matter. geekblogToC: 3 - # (Optional, default static/brand.svg) Set the path to a logo for the Geekblog - # relative to your 'static/' folder. - geekblogLogo: logo.png - # (Optional, default none) Add a link to your Legal Notice page to the site footer. # It can be either a remote url or a local file path relative to your content directory. geekblogLegalNotice: https://blog.example.com/legal diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 2fe8a7b..575f450 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -9,6 +9,7 @@ {{ partial "head/rel-me" . }} {{ partial "head/microformats" . }} {{ partial "head/others" . }} + {{ partial "head/schema.html" . }} diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml index 98d95b8..bd97f27 100644 --- a/layouts/_default/list.atom.xml +++ b/layouts/_default/list.atom.xml @@ -8,7 +8,7 @@ {{- end -}} {{- end -}} {{ printf `<![CDATA[%s]]>` $title | safeHTML }} - {{ with .Site.Params.GeekblogSubtitle }} + {{ with .Site.Params.subtitle }} {{ printf `` . | safeHTML }} {{ end }} {{ $output_formats := .OutputFormats }} diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html index d28c8ca..f19e80d 100644 --- a/layouts/partials/head/meta.html +++ b/layouts/partials/head/meta.html @@ -1,6 +1,6 @@ -{{ $description := default (default .Site.Title .Site.Params.Description) (default .Summary .Description) }} +{{ $description := default (default .Site.Title .Site.Params.description) (default .Summary .Description) }} {{ $keywords := default .Site.Params.Keywords .Keywords }} {{ $author := default (slice .Site.Params.GeekblogAuthor) .Params.authors }} {{ with $description }} diff --git a/layouts/partials/head/microformats.html b/layouts/partials/head/microformats.html index ff8a99b..47183f7 100644 --- a/layouts/partials/head/microformats.html +++ b/layouts/partials/head/microformats.html @@ -1,3 +1,2 @@ {{ template "_internal/opengraph.html" . }} {{ template "_internal/twitter_cards.html" . }} -{{ template "_internal/schema.html" . }} diff --git a/layouts/partials/head/schema.html b/layouts/partials/head/schema.html new file mode 100644 index 0000000..83820dd --- /dev/null +++ b/layouts/partials/head/schema.html @@ -0,0 +1,69 @@ +{{ if .IsHome -}} + +{{ else if .IsPage }} +{{ $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors }} +{{ $ac := 0 }} +{{ $ac_max := default 0 (len $authors) }} + +{{ end }} diff --git a/layouts/partials/site-header.html b/layouts/partials/site-header.html index af6903e..49fae99 100644 --- a/layouts/partials/site-header.html +++ b/layouts/partials/site-header.html @@ -2,10 +2,10 @@
- {{ .Site.Title }} + {{ .Site.Title }} {{ .Site.Title }} - {{ with .Site.Params.GeekblogSubtitle }} + {{ with .Site.Params.subtitle }} {{ . }} {{ end }}