From 1210306d64fdc7b05e06c6fdb8158f8473d589f7 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 16 Jul 2022 23:34:02 +0200 Subject: Provide ContactPage for Schema.org --- exampleSite/content/contact.md | 1 + layouts/partials/schema.org/article.html | 20 +++++++++++++------- layouts/partials/schema.org/website.html | 24 ++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/exampleSite/content/contact.md b/exampleSite/content/contact.md index e12a0bd..d46c277 100644 --- a/exampleSite/content/contact.md +++ b/exampleSite/content/contact.md @@ -1,6 +1,7 @@ --- title: Contact description: We'd love to hear from you +semanticType: contact --- This is an example of a custom shortcode that you can put right into your content. diff --git a/layouts/partials/schema.org/article.html b/layouts/partials/schema.org/article.html index b193acb..7fa3762 100644 --- a/layouts/partials/schema.org/article.html +++ b/layouts/partials/schema.org/article.html @@ -1,7 +1,9 @@ {{- /* Get schema type. */}} {{- $schemaType := "Article" -}} -{{- if (eq .Params.semanticType "about") -}} +{{- if (eq .Params.semanticType "contact") -}} + {{- $schemaType = "ContactPage" -}} +{{- else if (eq .Params.semanticType "about") -}} {{- $schemaType = "AboutPage" -}} {{- else if or (eq .Type "post") (eq .Type "posts") -}} {{- $schemaType = "BlogPosting" -}} @@ -19,11 +21,16 @@ "@type": "WebPage", "@id": {{ .Permalink }} }, - "headline": {{ partial "title.html" . | htmlUnescape }},{{ if .Params.featuredImage }} + "url": {{ .Permalink }}, + "headline": {{ partial "title.html" . | htmlUnescape }}, + "description": {{ partial "description.html" . }},{{ if .Params.featuredImage }} {{ $image := .Resources.GetMatch .Params.featuredImage -}} - "image": [ - {{ $image.Permalink }} - ],{{ end }} + "image": { + "@type": "ImageObject", + "url": {{ $image.Permalink }}, + "width": "{{ $image.Width }}", + "height": "{{ $image.Height }}" + },{{ end }} "keywords": {{ partial "keywords.html" . }}, "datePublished": {{ .Date.Format "2006-01-02T15:04:05Z07:00" }}, "dateModified": {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}, @@ -59,7 +66,6 @@ "@type": "ImageObject", "url": {{ $logo.Permalink | absURL }} } - }, - "description": {{ partial "description.html" . }} + } } diff --git a/layouts/partials/schema.org/website.html b/layouts/partials/schema.org/website.html index c06bd76..cde04ed 100644 --- a/layouts/partials/schema.org/website.html +++ b/layouts/partials/schema.org/website.html @@ -7,5 +7,25 @@ "keywords": {{ partial "keywords.html" . }} } -{{- /* TODO: Add "potentialAction" with search. - For more see: https://developers.google.com/structured-data/slsb-overview */ -}} + +{{- /* +TODO: Add "potentialAction" with a search entrypoint (now we have a search) + +For more see: +- https://developers.google.com/search/docs/advanced/structured-data/sitelinks-searchbox + +Example: +{ + "@context": "https://schema.org", + "@type": "WebSite", + "url": "https://www.example.com/", + "potentialAction": { + "@type": "SearchAction", + "target": { + "@type": "EntryPoint", + "urlTemplate": "https://query.example.com/search?q={search_term_string}" + }, + "query-input": "required name=search_term_string" + } +} +*/ -}} -- cgit v1.2.3