diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-06-05 14:50:21 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-06-05 14:50:21 +0200 |
| commit | e8614d96f44c290224ae65a2dd029acdff1d3c74 (patch) | |
| tree | cc40b30f3bd88648f7e60a220db20d1f68041565 /layouts/partials/schema.org | |
| parent | 6c6b1bd1035ae68a18bd83faf7ff1297ead60e8c (diff) | |
| download | gohugo-theme-ed-e8614d96f44c290224ae65a2dd029acdff1d3c74.tar.gz | |
Provided initial support os schema.org microdata
Diffstat (limited to 'layouts/partials/schema.org')
| -rw-r--r-- | layouts/partials/schema.org/article.html | 65 | ||||
| -rw-r--r-- | layouts/partials/schema.org/website.html | 10 |
2 files changed, 75 insertions, 0 deletions
diff --git a/layouts/partials/schema.org/article.html b/layouts/partials/schema.org/article.html new file mode 100644 index 0000000..ff1558b --- /dev/null +++ b/layouts/partials/schema.org/article.html @@ -0,0 +1,65 @@ +{{- /* Get schema type. */}} +{{ $schemaType := "Article" }} +{{ if or (eq .Type "post") (eq .Type "posts") }} + {{ $schemaType = "BlogPosting" }} +{{ end -}} + +{{- $publisher := site.Params.seo.publisher | default site.Title }} +{{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png") }} +{{ $logo = $logo.Resize "96x96" -}} + +<script type="application/ld+json"> + { + "@context": "https://schema.org", + "@type": {{ $schemaType }}, + "mainEntityOfPage": { + "@type": "WebPage", + "@id": {{ .Permalink }} + }, + "headline": {{ partial "title.html" . | htmlUnescape }},{{ if .Params.featured_image }} + {{ $image := .Resources.GetMatch .Params.featured_image -}} + "image": [ + {{ $image.Permalink }} + ],{{ end }} + "datePublished": {{ .Date.Format "2006-01-02T15:04:05Z07:00" }}, + "dateModified": {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}, + {{- if .Params.author }} + {{- $authorType := (printf "%T" .Params.author) }} + {{- if eq $authorType "string" }} + "author": { + "@type": "Person", + "name": {{ .Params.author }} + }, + {{- else if eq $authorType "[]string" }} + "author": [ + {{ range $i, $author := .Params.author }}{{ if $i }},{{ end }} + { + "@type": "Person", + "name": {{ $author }} + }{{ end }} + ], + {{- end }} + {{- else }} + {{- with site.Author.name }} + "author": { + "@type": "Person", + "name": {{ . }} + {{ with site.Author.twitter }}, + "url": "https://twitter.com/{{ . }}" + {{ end }} + }, + {{- end }} + {{- end }} + "publisher": { + "@type": "Organization", + "name": {{ $publisher }}, + "logo": { + "@type": "ImageObject", + "url": {{ $logo.Permalink | absURL }} + } + }, + "description": {{ partial "description.html" . }} + } +</script> + + diff --git a/layouts/partials/schema.org/website.html b/layouts/partials/schema.org/website.html new file mode 100644 index 0000000..ef6609e --- /dev/null +++ b/layouts/partials/schema.org/website.html @@ -0,0 +1,10 @@ +<script type="application/ld+json"> + { + "@context": "https://schema.org", + "@type": "WebSite", + "name": {{ partial "title.html" . }}, + "url": {{ site.BaseURL }} + } +</script> +{{- /* TODO: Add "potentialAction" with search. + For more see: https://developers.google.com/structured-data/slsb-overview */ -}} |
