我可以在 schema.org 中有重叠的东西吗
Can I have overlapping things in schema.org
我正在开发在地图上显示酒店的网站。用户登陆与某个地点关联的页面,我们会显示该地点所有酒店的地图(例如 Key West)。
我正在尝试改进我们使用的 schema.org 标记。目前页面的大部分被标记为 place. We then include the map in that markup. Then within all that we have individual hotels。所以我们的标记看起来像 -
<div id="mainwrap" itemscope itemtype="http://schema.org/Place">
<div id="map_canvas" style="height:100%;" itemprop="hasMap" itemscope itemtype="https://schema.org/Map"></div>
<div itemscope itemtype="http://schema.org/Hotel">...</div>
<div itemscope itemtype="http://schema.org/Hotel">...</div>
<div itemscope itemtype="http://schema.org/Hotel">...</div>
</div>
</div>
我认为使用 itemList. Then we can communicate how many hotels are in the list, how they're sorted, and even mark up some of the .
将所有内容标记为酒店列表更有意义
是否可能有重叠架构?因此,例如,我可以做这样的事情吗..
<div id="mainwrap" itemscope itemtype="http://schema.org/ItemList">
<div itemProp="PotentialAction" class="filterWidget">...</div>
<div itemProp="PotentialAction" class="sortWidget">...</div>
<div itemscope itemtype="http://schema.org/Place">
<div id="map_canvas" style="height:100%;" itemprop="hasMap" itemscope itemtype="https://schema.org/Map"></div>
<div itemProp="itemListElement" itemtype="http://schema.org/ListItem" itemscope itemtype="http://schema.org/Hotel">...</div>
<div itemProp="itemListElement" itemtype="http://schema.org/ListItem" itemscope itemtype="http://schema.org/Hotel">...</div>
<div itemProp="itemListElement" itemtype="http://schema.org/ListItem" itemscope itemtype="http://schema.org/Hotel">...</div>
</div>
</div>
</div>
还有什么好的方法可以测试其中的一些吗?问题是它是一个单页应用程序,测试工具需要原始 html(而 google 机器人将 运行 js 并呈现 dom)。
通过使用 ID
作为标识符,您已经完成了大部分工作。
例如,如果您将唯一的 ID
分配给酒店,则可以在不同的结构中使用该 ID,例如 Place
或 ItemList
。
您可以在 Google 结构数据测试工具 (GSDTT) 上测试结构:https://search.google.com/structured-data/testing-tool。
但是,您需要修复顶部示例中的 HTML,因为您有悬空的 <div>
。
复制上面的完整结构并将其粘贴到 GSDTT 上。 HTML 页面不是必需的;只有微数据结构。
我会说 Map
对于 Hotel
项目来说并不是真正有用的 "parent" 类型,这在 Schema.org 中是不可能的,因为 Map
没有定义 属性 可以引用地图中包含的 Place
个项目。
最基本的结构是一个 Place
项目(页面的主要主题)和几个与 containsPlace
property 关联的 Hotel
项目。另外指定 Map
。
<body itemscope itemtype="http://schema.org/WebPage">
<section itemprop="mainEntity" itemscope itemtype="http://schema.org/Place">
<div itemprop="hasMap" itemscope itemtype="http://schema.org/Map">
…
</div>
<ul>
<li itemprop="containsPlace" itemscope itemtype="http://schema.org/Hotel">…</li>
<li itemprop="containsPlace" itemscope itemtype="http://schema.org/Hotel">…</li>
<li itemprop="containsPlace" itemscope itemtype="http://schema.org/Hotel">…</li>
</ul>
</section>
</body>
如果您想对 Hotel
项使用 ItemList
,它会变得更加复杂。
然后就不能再使用containsPlace
,因为ItemList
不能有这个属性(好吧,实际上可以,但不是预期的)。您可以使用相反的 属性 containedInPlace
并引用 Place
项,但在我的示例中,不可能为此目的使用 Microdata 的 itemref
属性(因为mainEntity
属性 也将添加到 Hotel
,这不是预期的 属性)。
更强大(但可能不太受支持)的替代方法是使用 Microdata 的 itemid
属性。它用于为项目指定 URI(这些 URI 不一定必须指向页面,它们仅用作标识符;但强烈建议提供包含有关它的微数据的页面)。您的每个项目都可以获得一个 URI,然后您可以使用此 URI 作为通常期望另一个项目作为值的属性的值。
以上面的示例为例,但现在使用 itemid
(对于 Place
)、ItemList
和 containedInPlace
:
<body itemscope itemtype="http://schema.org/WebPage">
<section itemprop="mainEntity" itemscope itemtype="http://schema.org/Place" itemid="#thing">
<div itemprop="hasMap" itemscope itemtype="http://schema.org/Map">
…
</div>
<!-- note that this list doesn’t have to be a child of the <section> element -->
<ul itemscope itemtype="http://schema.org/ItemList">
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/Hotel">
<link itemprop="containedInPlace" href="#thing" />
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/Hotel">
<link itemprop="containedInPlace" href="#thing" />
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/Hotel">
<link itemprop="containedInPlace" href="#thing" />
</li>
</ul>
</section>
</body>
关于 itemid
和 URI 值
假设关于这个 Place
的页面有 URL http://example.com/places/amsterdam
。由于 itemid
值为 #thing
,因此完整的 URI 将为 http://example.com/places/amsterdam#thing
。
每当您在另一个页面上引用此 Place
时,您可以使用 http://example.com/places/amsterdam#thing
(如果您在同一页面上引用它,您也可以使用完整的 URI,或者再次使用#thing
)。这样做的好处是您不必重复数据(您可以参考其指定所有内容的 "canonical" 位置),但它的缺点是消费者必须访问另一个页面(但是,嘿,这是他们的工作).
区分页面的 /places/amsterdam
和位置的 /places/amsterdam#thing
,在语义网/关联数据世界中可能很重要 – more details in my answer to the question Best practices for adding semantics to a website.
我正在开发在地图上显示酒店的网站。用户登陆与某个地点关联的页面,我们会显示该地点所有酒店的地图(例如 Key West)。
我正在尝试改进我们使用的 schema.org 标记。目前页面的大部分被标记为 place. We then include the map in that markup. Then within all that we have individual hotels。所以我们的标记看起来像 -
<div id="mainwrap" itemscope itemtype="http://schema.org/Place">
<div id="map_canvas" style="height:100%;" itemprop="hasMap" itemscope itemtype="https://schema.org/Map"></div>
<div itemscope itemtype="http://schema.org/Hotel">...</div>
<div itemscope itemtype="http://schema.org/Hotel">...</div>
<div itemscope itemtype="http://schema.org/Hotel">...</div>
</div>
</div>
我认为使用 itemList. Then we can communicate how many hotels are in the list, how they're sorted, and even mark up some of the
是否可能有重叠架构?因此,例如,我可以做这样的事情吗..
<div id="mainwrap" itemscope itemtype="http://schema.org/ItemList">
<div itemProp="PotentialAction" class="filterWidget">...</div>
<div itemProp="PotentialAction" class="sortWidget">...</div>
<div itemscope itemtype="http://schema.org/Place">
<div id="map_canvas" style="height:100%;" itemprop="hasMap" itemscope itemtype="https://schema.org/Map"></div>
<div itemProp="itemListElement" itemtype="http://schema.org/ListItem" itemscope itemtype="http://schema.org/Hotel">...</div>
<div itemProp="itemListElement" itemtype="http://schema.org/ListItem" itemscope itemtype="http://schema.org/Hotel">...</div>
<div itemProp="itemListElement" itemtype="http://schema.org/ListItem" itemscope itemtype="http://schema.org/Hotel">...</div>
</div>
</div>
</div>
还有什么好的方法可以测试其中的一些吗?问题是它是一个单页应用程序,测试工具需要原始 html(而 google 机器人将 运行 js 并呈现 dom)。
通过使用 ID
作为标识符,您已经完成了大部分工作。
例如,如果您将唯一的 ID
分配给酒店,则可以在不同的结构中使用该 ID,例如 Place
或 ItemList
。
您可以在 Google 结构数据测试工具 (GSDTT) 上测试结构:https://search.google.com/structured-data/testing-tool。
但是,您需要修复顶部示例中的 HTML,因为您有悬空的 <div>
。
复制上面的完整结构并将其粘贴到 GSDTT 上。 HTML 页面不是必需的;只有微数据结构。
我会说 Map
对于 Hotel
项目来说并不是真正有用的 "parent" 类型,这在 Schema.org 中是不可能的,因为 Map
没有定义 属性 可以引用地图中包含的 Place
个项目。
最基本的结构是一个 Place
项目(页面的主要主题)和几个与 containsPlace
property 关联的 Hotel
项目。另外指定 Map
。
<body itemscope itemtype="http://schema.org/WebPage">
<section itemprop="mainEntity" itemscope itemtype="http://schema.org/Place">
<div itemprop="hasMap" itemscope itemtype="http://schema.org/Map">
…
</div>
<ul>
<li itemprop="containsPlace" itemscope itemtype="http://schema.org/Hotel">…</li>
<li itemprop="containsPlace" itemscope itemtype="http://schema.org/Hotel">…</li>
<li itemprop="containsPlace" itemscope itemtype="http://schema.org/Hotel">…</li>
</ul>
</section>
</body>
如果您想对 Hotel
项使用 ItemList
,它会变得更加复杂。
然后就不能再使用containsPlace
,因为ItemList
不能有这个属性(好吧,实际上可以,但不是预期的)。您可以使用相反的 属性 containedInPlace
并引用 Place
项,但在我的示例中,不可能为此目的使用 Microdata 的 itemref
属性(因为mainEntity
属性 也将添加到 Hotel
,这不是预期的 属性)。
更强大(但可能不太受支持)的替代方法是使用 Microdata 的 itemid
属性。它用于为项目指定 URI(这些 URI 不一定必须指向页面,它们仅用作标识符;但强烈建议提供包含有关它的微数据的页面)。您的每个项目都可以获得一个 URI,然后您可以使用此 URI 作为通常期望另一个项目作为值的属性的值。
以上面的示例为例,但现在使用 itemid
(对于 Place
)、ItemList
和 containedInPlace
:
<body itemscope itemtype="http://schema.org/WebPage">
<section itemprop="mainEntity" itemscope itemtype="http://schema.org/Place" itemid="#thing">
<div itemprop="hasMap" itemscope itemtype="http://schema.org/Map">
…
</div>
<!-- note that this list doesn’t have to be a child of the <section> element -->
<ul itemscope itemtype="http://schema.org/ItemList">
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/Hotel">
<link itemprop="containedInPlace" href="#thing" />
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/Hotel">
<link itemprop="containedInPlace" href="#thing" />
</li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/Hotel">
<link itemprop="containedInPlace" href="#thing" />
</li>
</ul>
</section>
</body>
关于 itemid
和 URI 值
假设关于这个 Place
的页面有 URL http://example.com/places/amsterdam
。由于 itemid
值为 #thing
,因此完整的 URI 将为 http://example.com/places/amsterdam#thing
。
每当您在另一个页面上引用此 Place
时,您可以使用 http://example.com/places/amsterdam#thing
(如果您在同一页面上引用它,您也可以使用完整的 URI,或者再次使用#thing
)。这样做的好处是您不必重复数据(您可以参考其指定所有内容的 "canonical" 位置),但它的缺点是消费者必须访问另一个页面(但是,嘿,这是他们的工作).
区分页面的 /places/amsterdam
和位置的 /places/amsterdam#thing
,在语义网/关联数据世界中可能很重要 – more details in my answer to the question Best practices for adding semantics to a website.