我正在尝试利用微数据来帮助搜索引擎定义网站的所有内容,以供其查看。
我有以下标记:
<!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
节点内链接页眉和页脚。
如何指示WPHeader
和WPHeader
是WPFooter
节点的一部分?
WPFooter
我找到了一种将所有3个节点合并到主节点WebPage
中的方法。但是,我使用了多个WebPage
或来做到这一点。我不确定
WebPage
是否是正确的方法。这种名称与名称相矛盾,因为应该始终在一个页面中包含主要内容。
这里是更新的HTML标记:
mainContentOfPage
您可以使用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