Close
Menu

RTCXpression

Structured Data Markup – It’s Not Easy to Comply with Google


July 25, 2017

It’s not easy to add structured data markup to a web page or website. That’s probably why a lot of web developers (and webmasters) ignore it. I ignored it while I was working on my custom WordPress theme.

It’s tedious to add any type of code I’m not familiar with and structured data markup is code. There are two preferred formats. Which one Google prefers depends on which of their pages you read.

Structured Data Markup Produces Rich Text Snippets

Google, Microsoft and Yahoo got together and created Schema.org in June of 2011. Yandex joined the fray in November of 2011.

The structured data markup they came up with helps their search engines pull rich text snippets from web pages to display in search results. If you use it with lists, reviews and other details, it can really spruce up the search results for certain pages.

The problem I faced when I started working on it with my theme is that I didn’t know which format Google prefers. This page says JSON-LD is their recommended format and explicitly says (emphasis mine):

Google recommends using JSON-LD for structured data whenever possible.

Another page says (in the FAQ section, emphasis mine):

Microdata and JSON-LD are two different ways to mark up your data using the schema.org vocabulary. It’s best to choose either microdata or JSON-LD and avoid using both types on a single page or email. Google prefers microdata for web content.

I guess some of Google’s documentation writers don’t check other pages. Anyway…

The JSON-LD format sits between HTML script tags, meant for JavaScript. While some search engines can read it, other’s can’t. All of them can read the microdata format, so that’s what I went with.


Microdata for the Home Page and Article Pages (Posts)

The static pages that never change, like the contact page and the pages containing links, can’t really benefit from structured data markup. The home page only needs something like this:

<div itemscope itemtype="http://schema.org/WebSite">
  <meta itemprop="name" content="RTCXpression">
  <meta itemprop="url" content="https://www.rtcx.net">
</div>
<div itemscope itemtype="http://schema.org/Person">
  <meta itemprop="name" content="RT Cunningham">
  <meta itemprop="url" content="https://www.rtcx.net">
  <meta itemprop="sameAs" content="https://www.facebook.com/richardtcunningham">
  <meta itemprop="sameAs" content="https://plus.google.com/+RTCunningham">
  <meta itemprop="sameAs" content="https://twitter.com/RTCXpression">
</div>

It identifies the website, the website owner, and the places associated with the website owner. The structure data markup for articles or posts is a little more in-depth:

<div itemscope itemType="http://schema.org/Article">
<meta itemprop="datePublished" content="2017-07-25">
<meta itemprop="dateModified" content="2017-07-25">
<meta itemprop="articleBody" content=" It’s not easy to add structured data markup to a web page or website. That’s probably why a lot of web developers (and webmasters) ignore it. I ignored it while I was working on my custom WordPress theme. It’s tedious to add any type of code I’m not familiar with and structured data markup is […]">
<meta itemprop="headline" content="Structured Data Markup – It’s Not Easy to Comply with Google">
<meta itemprop="mainEntityOfPage" content="https://www.rtcx.net/structured-data-markup.html">
<div itemprop="author" itemscope="" itemtype="http://schema.org/Person">
<meta itemprop="name" content="RT Cunningham">
</div>
<div itemprop="image" itemscope="" itemtype="https://schema.org/ImageObject">
<meta itemprop="url" content="https://www.rtcx.net/ifiles/structured-data-markup-300x202.jpg">
<meta itemprop="width" content="300">
<meta itemprop="height" content="300">
</div>
<div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">
<meta itemprop="name" content="RTCXpression">
<meta itemprop="url" content="https://www.rtcx.net">
<meta itemprop="description" content="The X Stands for Expression">
<div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
<meta itemprop="url" content="https://www.rtcx.net/ifiles/cropped-pen-1-300x300.png">
<meta itemprop="width" content="300">
<meta itemprop="height" content="300">
</div>
</div>
</div>

When I added this code, I used some WordPress functions. There are WordPress plugins that will do some of it, but not all of it. The WordPress functions I used are:

get_bloginfo('name')
home_url()
get_the_date('Y-m-d')
get_the_modified_date('Y-m-d')
get_the_excerpt()
get_the_title()
get_permalink()
get_the_author_meta('display_name')

$logo_url = 'https://www.rtcx.net/ifiles/cropped-pen-1-300x300.png';
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'medium');
if ($image_url == '') {
  $image_url = $logo_url;
}

The last section of code is there for one reason only: Not all of my articles have images in them. The customizer adds the logo in approved WordPress themes, but not in this one. I didn’t add customizer support. I copied my icon and logo code from my last theme.


Playing the Waiting Game

Now that all of my relevant pages have structured data markup, I have to wait for Google to re-index those pages. It can take weeks for them to get them all.

When I’m satisfied with the results in the Google Search Console (and I can double-check them with Google’s Structured Data Testing Tool), I’ll create a real plugin for this.

Those WordPress themes usually include the structured data markup inline, surrounding HTML tags already in place. I put all of mine in the footer of each relevant page, before any JavaScript code. I tested the markup up with Google’s tool, but the search engine bot may have a fit. Again, I’ll have to wait.

Please go to this alternate page if you would like read or post comments.

Share:

Categories: Technology

Tags: , , , , , , , , ,

Previous and Next Articles (if any):

« »

More

Please read some of my more important pages if you have the time:

Comments Policy           Privacy Policy

RTCXpression established Feb 28, 2011
Copyright © 2013-2017 RT Cunningham
Hosted at Digital Ocean