Микроданные HTML5 - ссылка на другой раздел (страница коллекции, содержащая все блоги)


В инструменте структурированного тестирования Google показано, что все они являются отдельными экземплярами. Я пытаюсь заставить их перечислить друг другу.

Вот что у меня сейчас есть:

<section class="primary content-area" itemscope itemtype="http://schema.org/CollectionPage">
    <meta itemprop="name headline" content="Stepanie Schaefer" />
    <div itemid="http://www.cheapflights.com/news/author/stephanieschaefer/" itemscope itemtype="http://schema.org/Person">
       <h1 itemprop="headline"><span itemprop="name">Stephanie Schaefer</span></h1>
       <p itemprop="description">Stephanie is a Boston native who loves to find ways to escape New England winters. She’s thrown a coin in the Trevi Fountain, sipped wine on a vineyard in Northern Spain and swam in the Mediterranean Sea. Although she hasn’t been everywhere, it’s definitely on her list.</p>
    </div>

        <div itemscope itemtype="http://schema.org/BlogPosting">
            <h1 itemprop="headline">Top 10 booze-infused getaways</h1>
            <link itemprop="author" href="http://www.cheapflights.com/news/author/stephanieschaefer/" />
            <p itemprop="description">Description of Blog</p>
        </div>

        <div itemscope itemtype="http://schema.org/BlogPosting">
            <h1 itemprop="headline">Top 10 booze-infused getaways</h1>
            <link itemprop="author" href="http://www.cheapflights.com/news/author/stephanieschaefer/" />
            <p itemprop="description">Description of Blog</p>
        </div>
</section>

Я попытался связать их вместе с itemref, но, похоже, это все еще не работает.

    <section class="primary content-area" itemscope itemtype="http://schema.org/CollectionPage" itemref="blogs1 blogs2">
    <meta itemprop="name headline" content="Stepanie Schaefer" />
    <div itemid="http://www.cheapflights.com/news/author/stephanieschaefer/" itemscope itemtype="http://schema.org/Person">
       <h1 itemprop="headline"><span itemprop="name">Stephanie Schaefer</span></h1>
       <p itemprop="description">Stephanie is a Boston native who loves to find ways to escape New England winters. She’s thrown a coin in the Trevi Fountain, sipped wine on a vineyard in Northern Spain and swam in the Mediterranean Sea. Although she hasn’t been everywhere, it’s definitely on her list.</p>
    </div>
        <div itemscope itemtype="http://schema.org/BlogPosting" id="blogs1">
            <h1 itemprop="headline">Top 10 booze-infused getaways</h1>
            <link itemprop="author" href="http://www.cheapflights.com/news/author/stephanieschaefer/" />
            <p itemprop="description">Description of Blog</p>
        </div>

        <div itemscope itemtype="http://schema.org/BlogPosting" id="blogs2">
            <h1 itemprop="headline">Top 10 booze-infused getaways</h1>
            <link itemprop="author" href="http://www.cheapflights.com/news/author/stephanieschaefer/" />
            <p itemprop="description">Description of Blog</p>
        </div>
</section>

Как нам связать два объекта "CollectionPage" и "BlogPosting" вместе?

Author: Yen Deng, 2016-09-13

1 answers

Вам нужно использовать свойства (itemprop), если вы хотите связать элементы.

Атрибут itemref можно использовать, если вы не можете вложить элементы, но вам все равно нужно использовать свойства. В вашем примере кажется, что вы можете вложить элементы, поэтому нет необходимости использовать itemref.

Как описано в мой ответ на ваш предыдущий вопрос, вы могли бы использовать mainEntity со значением ItemList (и в ItemList, itemListElement для каждого BlogPosting).

Другой вариант - использовать hasPart. Это менее выразительно, чем mainEntity/ItemList способ и использование blogPostBlog) может быть предпочтительнее, но это очень просто, поэтому он может проиллюстрировать, как он работает с микроданными.

Вложенность (без itemref)

<section itemscope itemtype="http://schema.org/CollectionPage">

  <article itemprop="hasPart" itemscope itemtype="http://schema.org/BlogPosting">
  </article>

  <article itemprop="hasPart" itemscope itemtype="http://schema.org/BlogPosting">
  </article>

</section>

itemref (без вложенности)

<section itemscope itemtype="http://schema.org/CollectionPage" itemref="blogs1 blogs2">
</section>

<!-- don’t nest this 'article' inside another element with 'itemscope' -->
<article itemprop="hasPart" itemscope itemtype="http://schema.org/BlogPosting" id="blogs1">
</article>

<!-- don’t nest this 'article' inside another element with 'itemscope' -->
<article itemprop="hasPart" itemscope itemtype="http://schema.org/BlogPosting" id="blogs2">
</article>

(SDTT Google выведет значение @id для этого примера, используя значения id, но это, скорее всего, ошибка. Вы можете "перезаписать" его, присвоив каждому BlogPosting значение itemid.)

 1
Author: unor, 2017-05-23 12:37:06