From 8ab05ae6255673cce8d133c00939808825dc3db6 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Fri, 20 Jan 2017 15:56:33 +0200 Subject: [PATCH] Add Schema.org implementation based on JSON-LD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This replaces the metadata that Hugo's own schema.html template had been providing, but does so in JSON-LD notation rather than via the use of tags (this is Google's currently recommended form of specifying this markup). There are a few exceptions where I did not follow the conventions used in Hugo's template, for example the use of up to six images from a post's frontmatter, because Google's tool only recognizes one image, as well as different logic for a post's publish and modified dates (using enableGitInfo = true). Using this new markup, Google's Structured Data Testing Tool is now able to understand site metadata much better (before it was reading none). The implementation here is a mix of the elements and types from the official Schema.org types—for example, Blog and BlogPosting—as well as from Google's search documentation. Note that Google's docs are geared towards AMP, where some metadata is required, while for non- AMP pages the metadata is just recommended. We will have to re-evaluate this in the future, for example to add height and width information to image metadata. See: https://schema.org/Blog See: https://schema.org/BlogPosting See: https://developers.google.com/search/docs/data-types/data-type-selector See: https://search.google.com/structured-data/testing-tool --- layouts/_default/baseof.html | 4 +++ layouts/_default/list.html | 25 ++++++++++++++++++ layouts/_default/single.html | 46 +++++++++++++++++++++++++++++++++ layouts/partials/head-meta.html | 1 - 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index f8867aa..e486e3b 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -4,6 +4,10 @@ {{ partial "head-meta.html" . }} + {{ block "schema-dot-org" . }} + + {{ end }} + {{ block "title" . }}{{ .Site.Title }}{{ end }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 60d6295..3aa7d31 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,3 +1,28 @@ +{{ define "schema-dot-org" }} + +{{ end }} + {{ define "main" }} {{ $paginator := .Paginate (where .Data.Pages "Type" "post") }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 8c2eb13..f8a628b 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,4 +1,50 @@ {{ define "title" }}{{ .Title | markdownify }} | {{ .Site.Title }}{{ end }} + +{{ define "schema-dot-org" }} + + +{{ end }} + {{ define "main" }} {{ $dateFormat := default "Mon Jan 2, 2006" (index .Site.Params "date_format") }} diff --git a/layouts/partials/head-meta.html b/layouts/partials/head-meta.html index 462ce1c..61a23c1 100644 --- a/layouts/partials/head-meta.html +++ b/layouts/partials/head-meta.html @@ -2,7 +2,6 @@ {{ template "_internal/opengraph.html" . }} -{{ template "_internal/schema.html" . }} {{ template "_internal/twitter_cards.html" . }} {{- with .Site.Params.google_verify_meta -}}