You are here

How to add rich snippets structured data on your Drupal 7 website

Submitted by Asif Nowaj, Last Modified on 2019-11-08

Lets first understand what is the Structured Data. Introduction of Structured Data.

Google says, “Structured data is a standardized format for providing information about a page and classifying the page content;”

Structured data is a markup code that contains defined schema terms and its values. These data helps search engines to understand the content of page and also the meaning of the page.

Search Engines also use the structured data to enable special search result features and enhancements. Google uses this structured data to display enhanced.

Google Search supports the following formats to read structured data.

  • JSON-LD [Recommended by Google]
  • Microdata
  • RDFa

We’ll use JSON-LD in this article. JavaScript notation embedded in a tag in the page head or body.

First create the structured data for one of your content. I am not going to describe here the detailed steps to generate structured data.

You can use Google’s “Structured Data Testing Tool” or “Structured Data Markup Helper”.
Structured Data Generation Tool

I have created “BreadcrumbList” structured data for one of my article https://everyething.com/How-to-Enable-TLS-protocols-in-Soap-UI

There are different types of structured data available and it depends which business you are doing and what type data would best for you.
Whether you are writing cooking recipe, your post is regarding a review of a book or gadget etc. Then you can select your intended structured data format.
Breadcrumb List Data

It shows the page position in the site hierarchy. A user can navigate different position in the site hierarchy. For details, you can see https://developers.google.com/search/docs/data-types/breadcrumbs
Content Search Result

Now I have my structured data in JSON-LD format for one of my article. Now we need to add this data to the content.
Okay let’s move into Drupal 7 and add a new field in the content type to hold the structured data step by step.
Go to “Configuration” => “Text formats” in Content Authoring.
Add Text Format Link

Add a new text format with name “Unaltered”, Select role “administrator”
Unaltered Text Format Values

Go to “Structure” => “Content Types”, Click on the “manage fields” of the selected content type for which you want to add the structured data. I have done this for my “Article” content type.
Content Type

“Add new field” named “Structured Data” and “FIELD TYPE” as “Long Text” and WIDGET “Text area (multiple rows)” as shown below.
Add New Field

Once the field is added, click on the “Edit”.
Structured Data Field Created

And make sure that “Text processing” is selected as “Filtered text (user selects text format)”
Text Processing

Now go to “Find Content” and find your article content where you want to add the structured data. For my case it I have opened my https://everyething.com/How-to-Enable-TLS-protocols-in-Soap-UI in edit mode.
Select text format as “Unaltered” and paste your structured data in the “Structured Data” field.
Structured Data In Content

Then save the content and wait for next time Google to crawl your content. Then your content will show the BreadcrubList in Google search result as mine.

In a nutshell, create a text format which supports everything provided even the script, and add a new field in your content type to provide the structured data and select appropriate text format for it.

Discussion or Comment

If you have anything in mind to share, please bring it in the discussion forum here.

https://forum.everyething.com/php-f36/