mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-25 14:30:39 +00:00
add json-ld structured data partial
This commit is contained in:
parent
247a1f7263
commit
07f124360d
@ -1,2 +1,6 @@
|
|||||||
|
- BREAKING
|
||||||
|
- rename description and keyword variables
|
||||||
|
- rename logo variable
|
||||||
|
- rename subtitle variable
|
||||||
- ENHANCEMENT
|
- ENHANCEMENT
|
||||||
- move description and keyword variables
|
- add partial for json-ld structured data
|
||||||
|
@ -54,13 +54,13 @@ outputs:
|
|||||||
enableRobotsTXT: true
|
enableRobotsTXT: true
|
||||||
|
|
||||||
params:
|
params:
|
||||||
images:
|
subtitle: Subtitle to describe your blog
|
||||||
- "favicon/android-chrome-512x512.png"
|
|
||||||
description: >
|
description: >
|
||||||
hugo-geekblog is a simple Hugo theme for personal blogs. This page is theme documentation
|
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.
|
and powered by the latest version of hugo-geekblog itself.
|
||||||
|
images:
|
||||||
|
- "favicon/android-chrome-512x512.png"
|
||||||
|
|
||||||
geekblogSubtitle: Subtitle to describe your blog
|
|
||||||
geekblogToC: 3
|
geekblogToC: 3
|
||||||
geekblogAuthor: john-doe
|
geekblogAuthor: john-doe
|
||||||
|
|
||||||
|
@ -88,19 +88,20 @@ enableGitInfo = true
|
|||||||
term = ["HTML", "ATOM"]
|
term = ["HTML", "ATOM"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
subtitle =
|
||||||
description = "This is my personal blog about tech."
|
description = "This is my personal blog about tech."
|
||||||
keywords = []
|
keywords = []
|
||||||
images = []
|
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.
|
# (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/)
|
# 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.
|
# You can also specify this parameter per page in front matter.
|
||||||
geekblogToC = 3
|
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.
|
# (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.
|
# It can be either a remote url or a local file path relative to your content directory.
|
||||||
geekblogLegalNotice = "https://blog.example.com/legal"
|
geekblogLegalNotice = "https://blog.example.com/legal"
|
||||||
@ -198,19 +199,20 @@ outputs:
|
|||||||
enableRobotsTXT: true
|
enableRobotsTXT: true
|
||||||
|
|
||||||
params:
|
params:
|
||||||
|
subtitle:
|
||||||
description: "This is my personal blog about tech."
|
description: "This is my personal blog about tech."
|
||||||
keywords: []
|
keywords: []
|
||||||
images: []
|
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.
|
# (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/)
|
# 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.
|
# You can also specify this parameter per page in front matter.
|
||||||
geekblogToC: 3
|
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.
|
# (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.
|
# It can be either a remote url or a local file path relative to your content directory.
|
||||||
geekblogLegalNotice: https://blog.example.com/legal
|
geekblogLegalNotice: https://blog.example.com/legal
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
{{ partial "head/rel-me" . }}
|
{{ partial "head/rel-me" . }}
|
||||||
{{ partial "head/microformats" . }}
|
{{ partial "head/microformats" . }}
|
||||||
{{ partial "head/others" . }}
|
{{ partial "head/others" . }}
|
||||||
|
{{ partial "head/schema.html" . }}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
|
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
|
||||||
{{ with .Site.Params.GeekblogSubtitle }}
|
{{ with .Site.Params.subtitle }}
|
||||||
{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}
|
{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ $output_formats := .OutputFormats }}
|
{{ $output_formats := .OutputFormats }}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
{{ $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 }}
|
{{ $keywords := default .Site.Params.Keywords .Keywords }}
|
||||||
{{ $author := default (slice .Site.Params.GeekblogAuthor) .Params.authors }}
|
{{ $author := default (slice .Site.Params.GeekblogAuthor) .Params.authors }}
|
||||||
{{ with $description }}
|
{{ with $description }}
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
{{ template "_internal/opengraph.html" . }}
|
{{ template "_internal/opengraph.html" . }}
|
||||||
{{ template "_internal/twitter_cards.html" . }}
|
{{ template "_internal/twitter_cards.html" . }}
|
||||||
{{ template "_internal/schema.html" . }}
|
|
||||||
|
69
layouts/partials/head/schema.html
Normal file
69
layouts/partials/head/schema.html
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{{ if .IsHome -}}
|
||||||
|
<script type="application/ld+json">
|
||||||
|
{
|
||||||
|
"@context": "http://schema.org",
|
||||||
|
"@type": "WebSite",
|
||||||
|
{{ with .Site.Params.GeekblogAuthor -}}
|
||||||
|
{{ with index $.Site.Data.authors . }}"author": "{{ .name }}",{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
"name": "{{ .Site.Title }}",
|
||||||
|
"url": "{{ .Site.BaseURL }}",
|
||||||
|
"description": "{{ .Site.Params.description }}",
|
||||||
|
"thumbnailUrl": "{{ (default "brand.svg" .Site.Params.logo) | absURL }}"{{ with .Site.Params.GeekblogContentLicense }},
|
||||||
|
"license": "{{ .name }}"{{ end }}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{{ else if .IsPage }}
|
||||||
|
{{ $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors }}
|
||||||
|
{{ $ac := 0 }}
|
||||||
|
{{ $ac_max := default 0 (len $authors) }}
|
||||||
|
<script type="application/ld+json">
|
||||||
|
{
|
||||||
|
"@context": "http://schema.org",
|
||||||
|
"@type": "BlogPosting",
|
||||||
|
"articleSection": "{{ .Section }}",
|
||||||
|
"name": "{{ .Title | safeJS }}",
|
||||||
|
"headline": "{{ .Title | safeJS }}",
|
||||||
|
"alternativeHeadline": "{{ .Params.lead }}",
|
||||||
|
"description": "{{ if .Description }}{{ .Description | safeJS }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ end }}{{ end }}",
|
||||||
|
"inLanguage": {{ .Site.Language.Lang }},
|
||||||
|
"isFamilyFriendly": "true",
|
||||||
|
"mainEntityOfPage": {
|
||||||
|
"@type": "WebPage",
|
||||||
|
"@id": "{{ .Permalink }}"
|
||||||
|
},
|
||||||
|
"author" : [
|
||||||
|
{{- with $authors -}}
|
||||||
|
{{- range sort . }}
|
||||||
|
{{- $ac = (add $ac 1) }}
|
||||||
|
{{- $author := index $.Site.Data.authors . }}
|
||||||
|
{
|
||||||
|
"@type": "Person",
|
||||||
|
"name": "{{ $author.name }}"
|
||||||
|
}{{ if lt $ac $ac_max }},{{ end }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
|
],
|
||||||
|
"copyrightHolder" : "{{ .Site.Title }}",
|
||||||
|
"copyrightYear" : "{{ .Date.Format "2006" }}",
|
||||||
|
"dateCreated": "{{ .Date.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
|
||||||
|
"datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
|
||||||
|
"dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
|
||||||
|
"publisher":{
|
||||||
|
"@type":"Organization",
|
||||||
|
"name": {{ .Site.Title }},
|
||||||
|
"url": {{ .Site.BaseURL }},
|
||||||
|
"logo": {
|
||||||
|
"@type": "ImageObject",
|
||||||
|
"url": "{{ (default "brand.svg" .Site.Params.logo) | absURL }}",
|
||||||
|
"width":"32",
|
||||||
|
"height":"32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"image": {{ if .Params.images }}[{{ range $i, $e := .Params.images }}{{ if $i }}, {{ end }}{{ $e | absURL }}{{ end }}]{{ else}}{{.Site.Params.logo | absURL }}{{ end }},
|
||||||
|
"url" : "{{ .Permalink }}",
|
||||||
|
"wordCount" : "{{ .WordCount }}",
|
||||||
|
"genre" : [ {{ range $index, $tag := .Params.tags }}{{ if $index }}, {{ end }}"{{ $tag }}" {{ end }}]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{{ end }}
|
@ -2,10 +2,10 @@
|
|||||||
<div class="container flex align-center justify-center">
|
<div class="container flex align-center justify-center">
|
||||||
<a class="gblog-header__link" rel="me" href="{{ .Site.BaseURL }}">
|
<a class="gblog-header__link" rel="me" href="{{ .Site.BaseURL }}">
|
||||||
<span class="gblog-brand flex align-center justify-center">
|
<span class="gblog-brand flex align-center justify-center">
|
||||||
<img class="gblog-brand__img" title="Branding of {{ .Site.Title }}" src="{{ (default "brand.svg" .Site.Params.GeekblogLogo) | relURL }}" alt="{{ .Site.Title }}" width=60 height=60>
|
<img class="gblog-brand__img" title="Branding of {{ .Site.Title }}" src="{{ (default "brand.svg" .Site.Params.logo) | relURL }}" alt="{{ .Site.Title }}" width=60 height=60>
|
||||||
{{ .Site.Title }}
|
{{ .Site.Title }}
|
||||||
</span>
|
</span>
|
||||||
{{ with .Site.Params.GeekblogSubtitle }}
|
{{ with .Site.Params.subtitle }}
|
||||||
<span class="gblog-brand__subtitle flex align-center justify-center">{{ . }}</span>
|
<span class="gblog-brand__subtitle flex align-center justify-center">{{ . }}</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user