如何使用Schema.org将页眉/页脚链接识别为WebPage定义的一部分?

问题描述 投票:1回答: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中查看以上内容时,它会检测到我想要的所有内容,除了每个元素的位置。

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

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

WPFooter

更新

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

这里是更新的HTML标记:

mainContentOfPage
html schema.org microdata
1个回答
0
投票

您可以使用mainEntity属性。

mainContentOfPage
<!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>
hasPart
© www.soinside.com 2019 - 2024. All rights reserved.