This document provides an overview of structured data and how to implement it in Drupal using the MetaTag and Schema Metatag modules. It discusses why structured data is useful for SEO, gives examples of rich snippets and knowledge graphs, and outlines how to set global and per-entity structured data defaults in Drupal. It also provides tips on validation and best practices for structured data implementation.
Structured SEO Data: An overview and how to for Drupal
1. Structured SEO Data:
An overview and how to for Drupal
Greg Monroe
SolarWind MSP
Drupal Camp Asheville 2019
The information here is my own and not the views of my employer
2. Why Use Structured Data?
Improved SEO results because it lets Search Engines understand
your content better
Enhanced display of your content in search results such as:
Site Information
Knowledge graphs
Product panels
Rich snippets
Use by aggregating sites
Better Social Sharing
Higher click thru rates and conversions
7. How did they do these?
Search Engine magic sauce…
Social Graphing… who you are, where you are,
what you are/have search(ing/ed) for.
Context specific results pages
Use site specific structured data to find and build
the results.
8. Structured Data Definition
Web pages are often filled with free form text, which
is easy for humans to read but more difficult for
computers to understand.
Structured data formats are rules that standardize the
structure and content of a web page. They are
additional markup that lets computers more easily
process the text meaning or semantics.
9. Structured Data
A Fractured Fairy Tale History
In the beginning… HTML metadata definitions: title,
description, keywords
The Babel Period: RSS, RDF, RDFa, Open Graph,
vCard/hCard, hCalendar, FOAF, Twitter Cards, and
the like.
Unified Field Theory – Schema.org
10. Schema.org
Schema.org is a collaborative, community activity with a
mission to create, maintain, and promote schemas for
structured data on the Internet.
The Schema.org vocabulary can be used with many different
encodings, including RDFa, Microdata and JSON-LD.
These vocabularies cover entities, relationships between
entities and actions, and can easily be extended through a
well-documented extension model.
See: http://www.schema.org/
11. Schemas
Schemas are a set of 'types' or classes, e.g. Organization
These types are arranged in a hierarchy. E.g.
Organization is derived from Thing and has multiple
subtypes like EducationalOrganization, Corporation,
LocalBusiness, and more.
Each type has a set of properties, e.g. Organization has a
name property
Types inherit properties from the type above them.
13. Type Properties Sample
Has 112 properties
Each has an expected
type the property
takes.
Some properties can
reference other
types.
14. Embedding Schema Information
Three choice:
Microdata – Requires span tags and special attributes
to be embedded in HTML
RDFa – Similar to Microdata but requires different
attributes inside the HTML
JSON-LD – Google’s preferred method. Information is
added in JSON format in the HTML as script tags of
type application/ld+json
16. Linking Objects with
JSON-LD Node Identifiers
@type: Organization
@id: http://my.org/#org
@type: Website
@id: http://my.org/#web
Publisher: {
@type: Organization,
@id: http://my.org/#org
}
InLanguage: en
WorkTranslation: {
@id: http://my.org/de#web
}
@type: Website
@id: http://my.org/de#web
Publisher: {
@type: Organization,
@id: http://my.org/#org
}
InLanguage: de
TranslationOfWork: {
@id: http://my.org/#web
}
See: https://www.w3.org/TR/2014/REC-json-ld-20140116/#node-identifiers
Note: The @id URI can be anywhere on the web, they just have to match.
17. Quick Case Study: Duke Health
Home Page
Organization
WebSite
Doctor Pages
Physician
AggregateRating
Clinic Pages
MedicalClinic
Person
Hospital Pages
Hospital
Doctor Search
AggregateRating
Blog Articles
Og:title, og:type,
Og:description,
Og:url, og:image,
Og:site_name
Event Pages
Event
Place
Notes:
●
Uses microdata
embedding (ld-json
was too new at the
time)
●
Blended Drupal /
AngularJS site so
most info built into
Angular code and
templates.
18. Structured Data in Drupal
MetaTag module with Schema.org Metatag FTW!
(drupal.org/project/metatag & drupal.org/project/schema_metatag)
Supports all the major structured data standards,
including the a growing group of Schema.org types
Global defaults based on Tags per content type
Allows for individual pages to be customized
I18N Support
Views support
19. A Quick Setup Guide
Add and enable the MetaTag module to your site
Recommended Submodules to enable:
Metatag: Open Graph
Metatag: Views
Schema.org Metatag
Schema.org Website
Schema.org Organization
Any other Schema type you think you will need.
20. A Quick Setup Guide (cont)
Go to Admin → Configuration → Search and Metadata
→ Metatag
Adjust the global and entity defaults.
To allow individual entities to be managed:
Go to the entity’s Manage Fields page
(Structure→Content Types)
Add a new field using the Meta Tags type.
If you are using translations, select “User may translate
this field”
32. Some Things to Know
The Schema Metatags modules add a large number
of fields to the edit forms… only use what you need.
Translation linkage properties are only available in
the dev version (Issue #3034233)
Don’t overuse common types like Organization /
Website. These should be on a few pages like the
home page or “About” pages.
33. Adding data via Code
Use the hook:
page_attachments_alter()
Add your JSON encoded
information to the
$attachments parameter.
$attachments['#attached']['html_head']
['my_custom_schema'] = [
[
'#type' => 'html_tag',
'#tag' => "script",
'#value' => theme_build_schema_elements(),
'#attributes' => [
'type' => 'application/ld+json',
],
],
];
34. Drupal Camp Ashville 2018
Questions?
?And Thank You
Google: Slideshare CGMonroe Stuctured Data
Drupal.org/u/cgmonroe