在微数据中使用meta标签指定复杂的结构 [英] Specifying complex structure with meta tag in Microdata

查看:83
本文介绍了在微数据中使用meta标签指定复杂的结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用微数据格式标记未显示在页面上的信息?

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

通常,我们不想在页面上显示发布者/作者的信息,但是Google要求文章"使用此信息,而且它们的结构很复杂.

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.

我不想将此数据放在隐藏的span/div或其他任何内容中,因此我认为我会使用meta标记.但是,如何使用metas指定发布者实体的徽标和名称?我需要以某种方式使用itemref吗?

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" /><!-- ??-->

我已经看过为文章中未显示的微数据使用其他图像吗?,但是无需使用JSON-LD就能实现我想要的功能吗?如果没有,我可以同时使用JSON-LD和元/标签描述吗?

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?

推荐答案

我认为您使用Microdata有两个(在某些情况下为三个)选项.

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元素是隐藏的,而除了meta/link元素之外不含其他任何元素的div元素也不会显示任何内容.

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

如果您不想使用div元素,则可以使用meta元素表示项目.但是然后您必须

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

  • 提供一个空的content属性(难看),并且
  • 对要添加到此项目的每个属性使用itemref属性.
  • 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>

请注意,这不适用于顶级商品,因为meta元素需要itemprop属性(不能为空).

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

在某些情况下,有可能引用项目的URI(而不是嵌入它们),例如,如果您的另一个页面包含有关发布者的数据.

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.

但是,请注意,尚不清楚Google是否支持.

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>

这篇关于在微数据中使用meta标签指定复杂的结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆