Schema.org <head> HTML markup: can I just use the meta tags?

﹥>﹥吖頭↗ 提交于 2019-12-04 12:51:52

Properties need to belong to an item. You create an item with the itemscope attribute (and the itemtype attribute can give this item a type).

Without itemscope, your markup example is invalid.

It is possible to provide Microdata only within the head element, but it’s not recommended for two reasons:

  • Microdata was intended to be used on your existing markup. While it can often make sense to include certain meta/link elements in the head (with itemref, see an example), most of the content is typically in the body. If you only want to use elements within head, you would have to duplicate most your content. But if you want to go that route, you might prefer to use JSON-LD.

  • As head doesn’t allow the use of a grouping element (like div), it gets complex to express Microdata. You would have to use itemref for every property and misuse an element like style for every item (see the first snippet in this answer as example).

Your example could look like this:

<head>
  <style itemscope itemtype="http://schema.org/Article" itemref="p1a p1b p1c"></style>
  <meta id="p1a" itemprop="name" content="The Name or Title Here">
  <meta id="p1b" itemprop="description" content="This is the page description">
  <link id="p1c" itemprop="image" href="http://www.example.com/image.jpg">
</head>

If you can use itemscope on the head element, it would be better:

<head itemscope itemtype="http://schema.org/Article">
  <meta itemprop="name" content="The Name or Title Here">
  <meta itemprop="description" content="This is the page description">
  <link itemprop="image" href="http://www.example.com/image.jpg">
</head>

But as soon as you need more than one item (which is typically the case, e.g., for the Organization/Person which is the author etc.), this doesn’t work anymore, and you would need a solution like in my first snippet.

Note that it’s allowed to use meta/link elements for Microdata within the body element. This makes it way easier, as you can use div elements for the itemscope. So even if you duplicate your content instead of marking up your existing content, it would be preferable to do this in the body:

<div itemscope itemtype="http://schema.org/Article">
  <meta itemprop="name" content="The Name or Title Here">
  <meta itemprop="description" content="This is the page description">
  <link itemprop="image" href="http://www.example.com/image.jpg">
</div>

(I replaced the meta element for the image property with a link element, because using meta is invalid for this purpose.)

According to the given example from scheme.org, yes both are compulsory for Google.

To validate whether your data is being captured properly you can use this tool:

Structured data testing tool

By using the tool above you can see that if you omit itemtype="http://schema.org/Article" the data will not get captured.

The section about Microdata on whatwg.org doesn't mention meta-elements in the head-element of a HTML document explicitly. In conclusion you need itemscope to have valid markup.

If you take a look at the description at schema.org you'll find this section about WebPages:

Every web page is implicitly assumed to be declared to be of type WebPage, so the various properties about that webpage, such as breadcrumb may be used. We recommend explicit declaration if these properties are specified, but if they are found outside of an itemscope, they will be assumed to be about the page.

The interesting part is this:

[…] if they [the properties] are found outside of an itemscope, they will be assumed to be about the page.

According to this you don't need to itemscope to the html-element. But it reads more like a suggestion then a definite specification.


You can see this behavior also in Google's Structured Data Testing Tool. When you run this code:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta itemprop="name" content="The Name or Title Here">
        <meta itemprop="description" content="This is the page description">
        <meta itemprop="image" content="http://www.example.com/image.jpg">
    </head>
</html>

… you'll find that it doesn't capture any data. It'll start capturing data, as soon as you add itemscope resulting in an Unspecified Type without any error:

Using itemtype="http://schema.org/Article" will fail or at least throw errors as too few properties are given for type Article.


All different types can be found on the WebPage overview on scheme.org. Maybe one is suitable for the whole page.

You can safely use <html itemscope itemtype="http://schema.org/Article">. This allows you to define itemprop's inside <head> element.

Google Rich Test Snippets and w3 validator, both validate this approach as I have already tested it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!