feat : Add Structured data schema support for Issue #98
Signed-off-by: GitHub Action <action@github.com>
This commit is contained in:
@ -9,6 +9,7 @@
|
|||||||
{{ $author := (.Params.author | default .Site.Params.author.name) -}}<meta name="author" content="{{ $author }}">
|
{{ $author := (.Params.author | default .Site.Params.author.name) -}}<meta name="author" content="{{ $author }}">
|
||||||
{{- with .Page.Params.description | default .Site.Params.description -}}<meta name="description" content="{{.}}">{{- end -}}
|
{{- with .Page.Params.description | default .Site.Params.description -}}<meta name="description" content="{{.}}">{{- end -}}
|
||||||
{{- partial "structure-extra.html" . -}}
|
{{- partial "structure-extra.html" . -}}
|
||||||
|
{{- partial "webschema.html" . -}}
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
{{ range .AlternativeOutputFormats -}}
|
{{ range .AlternativeOutputFormats -}}
|
||||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Title | safeHTML }}
|
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Title | safeHTML }}
|
||||||
|
69
layouts/partials/webschema.html
Normal file
69
layouts/partials/webschema.html
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{{- if .IsHome -}}
|
||||||
|
<script type="application/ld+json">
|
||||||
|
{
|
||||||
|
"@context" : "https://schema.org",
|
||||||
|
"@type" : "WebSite",
|
||||||
|
"name" : {{ site.Title }},
|
||||||
|
"description": {{ site.Params.description | plainify | truncate 180 | safeHTML }},
|
||||||
|
"logo": {{ site.Params.assets.favicon | default "favicon.ico" | absURL }},
|
||||||
|
"url" : {{ site.Home.Permalink }}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{{- else if .IsPage }}
|
||||||
|
<script type="application/ld+json">
|
||||||
|
{
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "BlogPosting",
|
||||||
|
"headline": {{ .Title | plainify}},
|
||||||
|
"name": "{{ .Title | plainify }}",
|
||||||
|
"description": {{ with .Description | plainify }}{{ . }}{{ else }}{{ .Summary | plainify }}{{ end -}},
|
||||||
|
"keywords": [
|
||||||
|
{{- if .Params.keywords -}}
|
||||||
|
{{ range $i, $e := .Params.keywords }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}
|
||||||
|
{{- else -}}
|
||||||
|
{{ range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}
|
||||||
|
{{- end -}}
|
||||||
|
],
|
||||||
|
"articleBody": {{ .Content | safeJS | htmlUnescape | plainify }},
|
||||||
|
"wordCount" : "{{ .WordCount }}",
|
||||||
|
"inLanguage": {{ .Language.Lang | default "en-us" }},
|
||||||
|
{{ if .Params.featuredImg -}}
|
||||||
|
"image":{{ .Params.featuredImg | absURL }},
|
||||||
|
{{- else if .Params.images -}}
|
||||||
|
{{- with .Params.images -}}
|
||||||
|
{{- range first 1 . -}}
|
||||||
|
"image":{{. | absURL}},
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
|
{{ end -}}
|
||||||
|
"datePublished": {{ .PublishDate }},
|
||||||
|
"dateModified": {{ .Lastmod }},
|
||||||
|
{{- if .Params.author }}
|
||||||
|
"author":{
|
||||||
|
"@type": "Person",
|
||||||
|
"name": {{ .Params.author }},
|
||||||
|
"url": {{ (ref . .Params.authorLink) | default (ref . .Site.Params.author.about) }}
|
||||||
|
}
|
||||||
|
{{ else }}
|
||||||
|
"author":{
|
||||||
|
"@type": "Person",
|
||||||
|
"name": {{ site.Params.author.name }},
|
||||||
|
"url": {{ ref . .Site.Params.author.about }}
|
||||||
|
}
|
||||||
|
{{ end -}}
|
||||||
|
"mainEntityOfPage": {
|
||||||
|
"@type": "WebPage",
|
||||||
|
"@id": {{ .Permalink | safeHTML }}
|
||||||
|
},
|
||||||
|
"publisher": {
|
||||||
|
"@type": "{{- ( site.Params.schema.publisherType | default "Organization") | title -}}",
|
||||||
|
"name": {{ site.Title }},
|
||||||
|
"description": {{ site.Params.description | plainify | truncate 180 | safeHTML }},
|
||||||
|
"logo": {
|
||||||
|
"@type": "ImageObject",
|
||||||
|
"url": {{ site.Params.assets.favicon | default "favicon.ico" | absURL }}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{{- end -}}
|
Reference in New Issue
Block a user