大网数据广告活动
网站运营与故障问答

Schema.org - Hierarchical or loose layout?

· 52CE 我爱测

I am tagging the product pages of a webshop using Schema.org. So far, I have used a hierarchical structure where the body tag is marked as ItemPage . Then I can use the property breadcrumb on ItemPage for my breadcrumbs, and anot…

问题原文

原帖链接 · Truls · CC BY-SA 3.0

I am tagging the product pages of a webshop using Schema.org. So far, I have used a hierarchical structure where the body tag is marked as ItemPage. Then I can use the property breadcrumb on ItemPage for my breadcrumbs, and another property mainEntity which is a Product. This does not give any warnings in the Structured Data testing Tool - the hierarchy is displayed here the way I intended.

But I wonder if Google would pick up my Product/Offer markup easier if it wasn't bundled within an ItemPage. That is, should I skip ItemPage and just have the Product as a loose elements, along with breadcrumbs, and other ItemLists?

Which is better?

Example of my hierarchical layout:

<body itemscope itemtype="http://schema.org/ItemPage">
    <div>Some other stuff...</div>
    <ol itemprop="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">
        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
            <a href="/a" itemprop="item"><span itemprop="name">A</span></a>
        </li>
        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
            <a href="/b" itemprop="item"><span itemprop="name">B</span></a>
        </li>
    </ol>
    <div itemprop="mainEntity" itemscope itemtype="http://schema.org/Product">
        <img src="/image.jpg" itemprop="image">
        <h1 itemprop="name">My Product</h1>
        <div itemprop="description">Example text</div>
        <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
            <meta itemprop="price" content="129">
            <meta itemprop="priceCurrency" content="SEK">
            <link itemprop="availability" href="http://schema.org/InStock">
            <meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition">
        </div>
    </div>
</body>

Example of loose tagging: (The BreadcrumbList and the Product are not "itemprop" of anything)

<body>
    <div>Some other stuff...</div>
    <ol itemscope itemtype="http://schema.org/BreadcrumbList">
        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
            <a href="/a" itemprop="item"><span itemprop="name">A</span></a>
        </li>
        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
            <a href="/b" itemprop="item"><span itemprop="name">B</span></a>
        </li>
    </ol>
    <div itemscope itemtype="http://schema.org/Product">
        <img src="/image.jpg" itemprop="image">
        <h1 itemprop="name">My Product</h1>
        <div itemprop="description">Example text</div>
        <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
            <meta itemprop="price" content="129">
            <meta itemprop="priceCurrency" content="SEK">
            <link itemprop="availability" href="http://schema.org/InStock">
            <meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition">
        </div>
    </div>
</body>

已采纳解答

原帖链接 · marcanuy · CC BY-SA 3.0

Your example of the hierarchical layout is very close to the suggested usage of the mainEntity property suggested by the official protocol documentation:

As mainEntity definition "indicates the primary entity described in some page", this is a perfect fit for your case, so my suggestion is that you choose this well structured code, Google should understand it perfectly.

This is the relevant code for this example used in schema.org main property:

<body itemscope itemtype="http://schema.org/WebPage">
...
<div itemprop="breadcrumb">
  <a href="category/books.html">Books</a> >
  <a href="category/books-literature.html">Literature & Fiction</a> >
  <a href="category/books-classics">Classics</a>
</div>
<div itemprop="mainEntity" itemscope itemtype="http://schema.org/Book">
<img itemprop="image" src="catcher-in-the-rye-book-cover.jpg"
     alt="cover art: red horse, city in background"/>
<span itemprop="name">The Catcher in the Rye</span> -
 <link itemprop="bookFormat" href="http://schema.org/Paperback">Mass Market Paperback
by <a itemprop="author" href="/author/jd_salinger.html">J.D. Salinger</a>
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
  <span itemprop="ratingValue">4</span> stars -
  <span itemprop="reviewCount">3077</span> reviews
</div>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
  Price: $<span itemprop="price">6.99</span>
  <meta itemprop="priceCurrency" content="USD" />
  <link itemprop="availability" href="http://schema.org/InStock">In Stock
</div>
Product details
<span itemprop="numberOfPages">224</span> pages
Publisher: <span itemprop="publisher">Little, Brown, and Company</span> -
 <meta itemprop="datePublished" content="1991-05-01">May 1, 1991
Language: <span itemprop="inLanguage">English</span>
ISBN-10: <span itemprop="isbn">0316769487</span>
</div>
...
</body>

The above example and yours, both are being fully processed by https://search.google.com/structured-data/testing-tool with very similar results.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。