Skip to content

Instantly share code, notes, and snippets.

@sutlxwhx
Last active August 21, 2018 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sutlxwhx/49f3dbfd8e6961bd9a819b7d55c15a31 to your computer and use it in GitHub Desktop.
Save sutlxwhx/49f3dbfd8e6961bd9a819b7d55c15a31 to your computer and use it in GitHub Desktop.
Rich snippet with star rating in SERP for your website / article

Introduction

According to Google Introduction to Structured Data either schema.org or JSON-LD markup should be enough for Google to pickup structuted data on your website / article. I used them both. In my experince Google was able to pickup breadcrubs within JSON-LD faster while star rating with schema.org was easily to implement.

Installation

Because most of the code is not visible to visitors and it's ok you you split your breadcrumbs and star rating into different instances on the page I encourage you to set the rating data over the h1 tag. It's better if you use div itemprop="name" and it's bad if you will create 2 isntances of h1 tag just to fit my example.

  • h1 stands for your h1 tag
  • "ratingValue" determines the final rating of your article
  • "bestRating" determines the best score for your article
  • "ratingCount" determines the amount of people who rated your article
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
	<div itemprop="name"><h1></h1></div>
	<meta itemprop="ratingValue" content="" />
	<meta itemprop="bestRating" content="" />
	<meta itemprop="ratingCount" content="" />
	<div itemprop="itemReviewed" itemscope itemtype="http://schema.org/CreativeWork"></div>
</div>

More on this

If you want a stanalone rich data generator for your article you can use either this Schema Markup Generator (JSON-LD) or this Schema.org JSON-LD Generator.
When I was learning how to implement rich snippets for my websites I spent some time with them both just to figure this thing out.

Verify

Use Google Structured Data Testing Tool to test your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment