David
David

Reputation: 34435

Specifying complex structure with meta tag in Microdata

How can I tag information that is not displayed on the page with the Microdata format?

Typically, we do not want to display publisher/author info on the page, but Google requires this info for Articles, and they have a complex structure.

I do not want to put this data in hidden span/div or anything, so I thought I'd use the meta tag. But how do I specify the logo and name of the publisher entity using metas? Do I need to use itemref somehow?

<section itemscope itemtype="http://schema.org/Article">
 <meta itemprop="keywords" content="kw1, kw2" />
 <meta itemprop="publisher" content="© My Company" /><!-- ??-->

I've already looked at Using a different image for microdata that isn't displayed in the article?, but is it possible to achieve what I want without using JSON-LD? If no, can I use both JSON-LD and meta/tag descriptions?

Upvotes: 4

Views: 580

Answers (1)

unor
unor

Reputation: 96587

I think you have two (in some cases three) options using Microdata.

meta/link + div

The most simple solution is to use meta/link elements for properties with non-item values, and div elements for properties with item values.

<section itemscope itemtype="http://schema.org/Article">
  <meta itemprop="keywords" content="kw1, kw2" />
  <div itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="My Company" />
  </div>
</section>

meta/link elements are hidden by default, and div elements that contain nothing else than meta/link elements don’t show anything either.

meta/link + itemref

If you don’t want to use div elements, it’s possible to use meta elements for representing an item. But then you have to

  • provide an empty content attribute (ugly), and
  • use the itemref attribute for every property you want to add to this item.
<meta itemscope itemprop="publisher" content="" itemtype="https://schema.org/Organization" id="pub" itemref="pub-name" />

<meta itemprop="name" content="My Company" id="pub-name" />

<section itemscope itemtype="http://schema.org/Article" itemref="pub">
  <meta itemprop="keywords" content="kw1, kw2" />
</section>

Note that this does not work for top-level items, because the meta element requires an itemprop attribute (which can’t be empty).

(meta/link +) itemid

In some cases it might be possible to reference URIs for the items (instead of embedding them), e.g., if you have another page that contains the data about the publisher.

However, note that it’s not clear if Google supports this.

<section itemscope itemtype="http://schema.org/Article">
  <meta itemprop="keywords" content="kw1, kw2" />
  <link itemprop="publisher" href="/publisher#this" />
</section>
<!-- on the page /publisher -->

<section itemscope itemtype="http://schema.org/Organization" itemid="#this">
  <h1 itemprop="name">My Company</h1>
</section>

Upvotes: 6

Related Questions