在单个页面中可多次使用的ItemList的替代

时间:2019-01-08 13:21:33

标签: laravel-5.4 schema.org

我正在创建工作门户,并且在主页中,其中有4个滑块,它们显示以下内容:

  • 滑块1:特色公司
  • 滑块2:推荐职位
  • 滑块3:按国家/地区划分的职位
  • 滑块4:按类别/行业分类的工作

这4个滑块的共同点是:
背景图片,标题,副标题和URL

我应该使用哪种模式?

我尝试使用ItemList,但在Google结构化数据测试工具上似乎无法使用。

我得到的错误是:

Multiple ItemList markups on a page are not allowed.

这是ItemList的代码段。这四个滑块的格式相似。

@if (!empty($countries))
  <div itemscope itemtype="http://schema.org/ItemList">
    <h2 class="mt-5" itemprop="name">Check Out This Featured Companies</h2>
    <div class="featuredCompaniesDiv mb-5 pb-5">
      <div class="row mb-5">
        <div class="col-xs-12">                
          <div class="featuredCompanies">
            <?php $countriesCount = 1; ?>
            @foreach($countries as $country)
              <div class="featuredCompanies--item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
                <meta itemprop="position" content="{{ $countriesCount }}">
                <meta itemprop="name" content="{{ $country->company_name }}">
                <meta itemprop="url" content="{{ action('PublicController@jobsByCountry', ['country' => $country->address_format]) }}">
                <a class="inner-div" href="{{ action('PublicController@jobsByCountry', ['country' => $country->address_format]) }}">
                  <span class="post-featured-img">
                    <img src="/img/spacer.png" data-lazy="/img/cnt/{{ $country->iso_code_3 }}.jpg" alt="Buick Enspire" width="700" height="323">
                  </span>
                  <h3 class="top-h3">{{ $country->name }}
                    @if ($country->cnt == 1)
                      <small>({{ $country->cnt }} Job)</small>
                    @else
                      <small>({{ $country->cnt }} Jobs)</small>
                    @endif
                  </h3>
                </a>
              </div>
              <?php $countriesCount++; ?>
            @endforeach
          </div>
        </div>
      </div>
    </div>
  </div>
@endif

1 个答案:

答案 0 :(得分:1)

通过https://webmasters.stackexchange.com/questions/98556/what-is-the-correct-way-to-use-the-collectionpage-type-for-a-category-page

找到了解决方案

错误现在消失了。

这是最终代码:

@if (!empty($countries))
    <div itemscope itemtype="http://schema.org/CollectionPage">
      <h2 class="mt-5" itemprop="name">Check Out This Featured Companies</h2>
      <div class="featuredCompaniesDiv mb-5 pb-5" itemprop="hasPart">
        <div class="row mb-5">
          <div class="col-xs-12">                
            <div class="featuredCompanies">
              <?php $countriesCount = 1; ?>
              @foreach($countries as $country)
                <div class="featuredCompanies--item" itemscope itemtype="http://schema.org/ItemPage">
                  <meta itemprop="position" content="{{ $countriesCount }}">
                  <meta itemprop="name" content="Jobs near {{ $country->name }}">
                  <meta itemprop="url" content="{{ action('PublicController@jobsByCountry', ['country' => $country->address_format]) }}">
                  <a class="inner-div" href="{{ action('PublicController@jobsByCountry', ['country' => $country->address_format]) }}">
                    <span class="post-featured-img">
                      <img src="/img/spacer.png" data-lazy="/img/cnt/{{ $country->iso_code_3 }}.jpg" alt="Buick Enspire" width="700" height="323">
                    </span>
                    <h3 class="top-h3">{{ $country->name }}
                      @if ($country->cnt == 1)
                        <small>({{ $country->cnt }} Job)</small>
                      @else
                        <small>({{ $country->cnt }} Jobs)</small>
                      @endif
                    </h3>
                  </a>
                </div>
                <?php $countriesCount++; ?>
              @endforeach
            </div>
          </div>
        </div>
      </div>
    </div>
@endif