Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you put Schema Microdata meta tags in the html body?

I have searched for a long time across the internet and stackoverflow for an answer to this question, and I have found links that say that you should not put meta tags in the body:

  • Using HTML5+Microdata's <meta> tag in the <body>
  • passing meta data in body part
  • Meta Tags In Body

while the schema.org website clearly shows the meta tags being nested directly in the body http://schema.org/AggregateRating

Just look at the example that is posted there

 Customer reviews:    <div itemprop="reviews" itemscope itemtype="http://schema.org/Review">     <span itemprop="name">Not a happy camper</span> -     by <span itemprop="author">Ellie</span>,     <meta itemprop="datePublished" content="2011-04-01">April 1, 2011     <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">       <meta itemprop="worstRating" content = "1">       <span itemprop="ratingValue">1</span>/       <span itemprop="bestRating">5</span>stars     </div>     <span itemprop="description">The lamp burned out and now I have to replace     it. </span>   </div>    <div itemprop="reviews" itemscope itemtype="http://schema.org/Review">     <span itemprop="name">Value purchase</span> -     by <span itemprop="author">Lucas</span>,     <meta itemprop="datePublished" content="2011-03-25">March 25, 2011     <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">       <meta itemprop="worstRating" content = "1"/>       <span itemprop="ratingValue">4</span>/       <span itemprop="bestRating">5</span>stars     </div>     <span itemprop="description">Great microwave for the price. It is small and     fits in my apartment.</span>   </div> 

If you were to keep the meta tags in the <head>, then how would you relate these two dates to their reviews? <meta itemprop="datePublished" content="2011-04-01"> <meta itemprop="datePublished" content="2011-03-25">

This is causing confusion and I would like to know how to do it properly.

like image 755
Timo Huovinen Avatar asked Apr 23 '12 11:04

Timo Huovinen


People also ask

Where do I put schema markup in HTML?

But for the most part, you will want to place the schema markup HTML in the footer of every page of your website. We are going to do that by clicking on Appearance, then Customize, then Widgets, and then the footer section in which we want to place the code.

Do meta tags go in the body section?

META tags are only allowed within HEAD (just like, say, TITLE) so by putting it into a BODY, you're essentially creating an invalid markup.

What is microdata schema?

Schema.org (often called schema) is a semantic vocabulary of tags (or microdata) that you can add to your HTML to improve the way search engines read and represent your page in SERPs.


2 Answers

If a meta element

  • has an itemprop attribute and a content attribute, and
  • has no name attribute, no http-equiv attribute, and no charset attribute,

then it’s valid to have this meta in the body. (If the value is a URL, you must use link instead.)

Why? Because the Microdata specification changes HTML5.

(Note that RDFa also changes HTML5 by allowing meta in the body in some cases.)


If you were to keep the meta tags in the <head>, then how would you relate these two dates to their reviews?

You could use the itemref attribute:

<!DOCTYPE html> <html> <head>   <title>Using itemref for meta in the head</title>   <meta itemprop="datePublished" content="2011-03-25" id="date"> </head> <body>    <div itemscope itemtype="http://schema.org/Review" itemref="date">     <span itemprop="name">…</span>   </div>  </body> </html> 

itemref takes a space-separated list of id values, so you can even reference two or more elements. Just add the id of all elements (containing itemprop attributes) that should be added to the item to its itemref attribute, e.g.: itemref="date author rating".

like image 138
unor Avatar answered Oct 14 '22 20:10

unor


Remember also that it's possible to totally avoid HTML markup and use JSON-LD markup entirely contained in the <head> anywhere in the HTML document (even dynamically injected!) like this:

<script type="application/ld+json"> {   "@context": "http://schema.org",   "@type": "Restaurant",   "name": "Fondue for Fun and Fantasy",   "description": "Fantastic and fun for all your cheesy occasions",   "openingHours": "Mo,Tu,We,Th,Fr,Sa,Su 11:30-23:00",   "telephone": "+155501003333",   "menu": "http://example.com/menu" } </script> 

have a look at the examples in schema.org, they usually contain JSON example markups like this https://schema.org/Restaurant.

Here is another good article about it http://www.seoskeptic.com/json-ld-google-knowledge-graph-schema-org-seo/

like image 40
Gruber Avatar answered Oct 14 '22 18:10

Gruber