如何使用schema.org将页脚链接识别为Web页定义的一部分?

问题描述 投票:0回答:1

[我正在尝试利用微数据来帮助搜索引擎定义网站的所有内容,以供其查看。

我有以下标记

<!DOCTYPE html>
<html lang="en" dir="ltr" itemscope itemtype="http://schema.org/WebPage">
<head>
    <link itemprop="url" href="https://example.com/link-to-canonical-url-of-this-page" />
</head>
<body>

    <div itemprop="isPartOf" itemscope itemtype="https://schema.org/WebSite">
        <link itemprop="url" href="https://example.com" />
    </div>
    <header itemscope itemtype="https://schema.org/WPHeader">
        <ul class="list-unstyled mb-0 pb-0 mt-2" itemprop="citation" itemscope="" itemtype="http://www.schema.org/SiteNavigationElement">
          <li>
          <a title="" itemprop="url" href="/some-uri" class="btn btn-link text-white" style="font-size: larger;">
          <strong itemprop="name">Popular Searches</strong>
          </a>
          <meta itemprop="position" content="1">
          </li>
        </ul>
    </header>
    <main role="main">
    </main>

    <footer itemscope itemtype="https://schema.org/WPFooter">
        <ul class="list-unstyled mb-0 pb-0 mt-2" itemprop="citation" itemscope="" itemtype="http://www.schema.org/SiteNavigationElement">
          <li>
          <a title="" itemprop="url" href="/some-uri" class="btn btn-link text-white" style="font-size: larger;">
          <strong itemprop="name">Popular Searches</strong>
          </a>
          <meta itemprop="position" content="1">
          </li>
        </ul>
    </footer>
</body>
</html>

但是当我在Structured Data Testing Tool中查看以上内容时,它将检测到我期望每个元素位置的所有内容。

该工具将数据检测为三个不同的节点。由于所有这些节点都是WebSite或WebPage的一部分,因此我希望以某种方式在WebPage节点内链接页眉和页脚。

如何指示WPHeaderWPFooterWebPage节点的一部分?

enter image description here

UPDATED我找到了一种将所有3个节点组合到主WebPage中的方法。但是,我使用了多个mainContentOfPagemainEntity来做到这一点。我不确定mainContentOfPage是否是正确的方法。这种名称与名称相矛盾,因为应该始终在一个页面中包含主要内容。

这里是更新的HTML标记

<!DOCTYPE html>
<html lang="en" dir="ltr" itemscope itemtype="http://schema.org/WebPage">
<head>
    <link itemprop="url" href="https://example.com/link-to-canonical-url-of-this-page" />
</head>
<body itemprop="mainContentOfPage">
    <div itemprop="isPartOf" itemscope itemtype="https://schema.org/WebSite">
        <link itemprop="url" href="https://example.com" />
    </div>
    <header itemprop="mainContentOfPage" itemscope itemtype="https://schema.org/WPHeader">
        <ul class="list-unstyled mb-0 pb-0 mt-2" itemprop="mainEntity" itemscope="" itemtype="http://www.schema.org/SiteNavigationElement">
          <li>
          <a title="" itemprop="url" href="/some-uri" class="btn btn-link text-white" style="font-size: larger;">
          <strong itemprop="name">Popular Searches</strong>
          </a>
          <meta itemprop="position" content="1">
          </li>
        </ul>
    </header>
    <main role="main">
    </main>
    <footer itemprop="mainContentOfPage" itemscope itemtype="https://schema.org/WPFooter">
        <ul class="list-unstyled mb-0 pb-0 mt-2" itemprop="mainEntity" itemscope="" itemtype="http://www.schema.org/SiteNavigationElement">
          <li>
          <a title="" itemprop="url" href="/some-uri" class="btn btn-link text-white" style="font-size: larger;">
          <strong itemprop="name">Popular Searches</strong>
          </a>
          <meta itemprop="position" content="1">
          </li>
        </ul>
    </footer>
</body>
</html>
html schema microdata structured-data
1个回答
0
投票

您可以使用hasPart属性。

hasPart
<html itemscope itemtype="http://schema.org/WebPage">
  <div itemprop="isPartOf" itemscope itemtype="http://schema.org/WebSite">
  </div>

  <header itemprop="hasPart" itemscope itemtype="http://schema.org/WPHeader">
    <nav itemprop="hasPart" itemscope itemtype="http://schema.org/SiteNavigationElement">
    </nav>
  </header>

  <main>
    <article itemprop="mainEntity" itemscope itemtype="http://schema.org/CreativeWork">
    </article>
  </main>

  <footer itemprop="hasPart" itemscope itemtype="http://schema.org/WPFooter">
    <ul itemprop="hasPart" itemscope itemtype="http://schema.org/SiteNavigationElement">
    </ul>
  </footer>
© www.soinside.com 2019 - 2024. All rights reserved.