Google Structured Data

Categories

SEO

Component ID

2843647

Component name

Google Structured Data

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

Synopsis

This nodule adds some of the Google Structured Data features to a website.
The Structured Data is represented in JSON-LD format, as this is the recommended option for Google.

From Google docs:

When you provide structured data markup for your online content, you make that content eligible to appear in two categories of Google Search features:

Rich results—Structured data for things like recipes, articles, and videos can appear in Rich Cards, as either a single element or a list of items. Other kinds of structured data can enhance the appearance of your site in Search, such as with Breadcrumbs, or a Sitelinks Search Box.
Knowledge Graph cards—If you're the authority for certain content, Google can treat the structured data on your site as factual and import it into the Knowledge Graph, where it can power prominent answers in Search and across Google properties. Knowledge Graph cards appear for authoritative data about organizations, and events. Movie reviews, and movie/music play actions, while based on ranking, can also appear in Knowledge Graph cards once they are reconciled to Knowledge Graph entities.

So far the features included are:

Roadmap

Upcoming features to be added:

  • Corporate Contacts
  • Breadcrumbs
  • Local Businesses
  • Music
  • TV & Movies
  • Videos
  • Products
  • Reviews
  • Recipes
  • Events
  • Books
  • Courses
  • Articles
  • Science Datasets

JSON-LD: This module is focused on the JSON-LD markup. It outputs Drupal entities as JSON-LD.

Structured Data (JSON+LD Rich Snippets): This module creates some basic structured data, but it's not compliant with the markup that Google expects to find in your site.

Structured Data Markup (sdm): A wider approach to add general purpose Structured Data Markup (not only that useful for Google) through the creation of entities and the use of the Context module, which is a very different approach from the one used here.

Known problems

Some themes (Bootstrap, Adaptive Theme) implement code to remove the 'type' attribute from <script> tags. You will most likely have to patch or modify a small bite of code to get the markup generated by this module correctly rendered.
This issue has been found in Adaptive Theme 7.x-3.x. The solution goes over either commenting this line in at_core/inc/process.inc

unset($tag['#attributes']['type'], $tag['#value_prefix'], $tag['#value_suffix']);

or adding some extra 'if' to avoid the theme to remove the 'application/ld+json' atribute.

function adaptivetheme_process_html_tag(&$vars) {
  $tag = &$vars['element'];

  if ($tag['#tag'] === 'style' || $tag['#tag'] === 'script') {

    // Remove redundant type attribute and CDATA comments.
    if ($tag['#attributes']['type'] != 'application/ld+json') // Added line to
    { // bypass 'application/ld+json'
      unset($tag['#attributes']['type'], $tag['#value_prefix'], $tag['#value_suffix']);
    }

    // Remove media="all" but leave others unaffected.
    if (isset($tag['#attributes']['media']) && $tag['#attributes']['media'] === 'all') {
      unset($tag['#attributes']['media']);
    }
  }
}

Credits

Developer: Jorge Alcauza https://www.drupal.org/u/alcauza