在搜索引擎优化方面...
难道最好把计划上包含所有链接的家长吗?
<nav itemscope="itemscope" itemtype="http://www.schema.org/SiteNavigationElement">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</nav>
......或者应该每一个环节被认为是它自己的元素吗?
<nav>
<span itemscope="itemscope" itemtype="http://www.schema.org/SiteNavigationElement">
<a itemprop="url" href="#">
<span itemprop="name">Link 1</span>
</a>
</span>
<span itemscope="itemscope" itemtype="http://www.schema.org/SiteNavigationElement">
<a itemprop="url" href="#">
<span itemprop="name">Link 2</span>
</a>
</span>
<span itemscope="itemscope" itemtype="http://www.schema.org/SiteNavigationElement">
<a itemprop="url" href="#">
<span itemprop="name">Link 3</span>
</a>
</span>
</nav>
Answer 1:
如果SiteNavigationElement
是为整个导航(即导航链接列表),你的第一个例子是正确的。
如果SiteNavigationElement
是为一个单一的导航条目(即,在导航链接列表的链接),你的第二个例子是正确的。
我认为Schema.org不明白地定义其变体的意思,因为他们只会说:
页面的导航元素。
然而,父类型WebPageElement
定义为:
一个网页元件,像一个表或图像
此外,所有的其他子类型(如Table
或WPFooter
)似乎是用于整个事情,而不是事物的特定部分。
因此,这似乎表明,整个导航应标明了,不是每个单独的链接:
<nav itemscope itemtype="http://schema.org/SiteNavigationElement">
<ul>
<li><a href="/link-1">Link 1</a></li> <!-- don’t use the 'url' or 'name' property here! -->
<li><a href="/link-2">Link 2</a></li>
</ul>
</nav>
在这种情况下,所有的属性属于整个导航,所以这意味着url
属性将指定此导航URL(在这个导航的链接不是网址!)。
Answer 2:
根据搜索引擎的土地 ,它应该是这样的:
<ul itemscope itemtype="http://www.schema.org/SiteNavigationElement">
<li itemprop="name">
<a itemprop="url" href="#">Link 1</a>
</li>
<li itemprop="name">
<a itemprop="url" href="#">Link 2</a>
</li>
<li itemprop="name">
<a itemprop="url" href="#">Travel Resources</a>
</li>
</ul>
Answer 3:
第一个答案是正确的,但我会混合使用这两个对(HTML5-)语义:
<nav itemscope itemtype="http://schema.org/SiteNavigationElement">
<ul>
<li>
<a itemprop="url" href="http://example.com/">
<span itemprop="name">Link 1</span>
</a>
</li>
</ul>
</nav>
Answer 4:
<nav role="navigation">
<ul role="menubar" aria-activedescendant="">
<li role="presentation" itemscope itemtype="https://schema.org/SiteNavigationElement">
<a href="" role="menuitem" tabindex="-1" itemprop="url">
<span itemprop="name">Link 1</span>
</a>
</li>
</ul>
</nav>
Answer 5:
schema.org/SiteNavigationElement扩展WebPageElement并且可以用来加价环节,这往往使良好的上下文链接。 您可以使用此模式为您的网页菜单。
<nav role="navigation" itemscope itemtype="http://schema.org/SiteNavigationElement">
<ul>
<li>
<a href="https://yoursite.com/" title="Link to Home" itemprop="url">
<span itemprop="name">Home</span>
</a>
</li>
<li>
<a href="https://yoursite.com/sample-page" title="Link to sample page" itemprop="url">
<span itemprop="name">sample page</span>
</a>
</li>
</ul>
Answer 6:
我认为最高贵的解决办法是使用hasPart属性。
<nav itemscope="itemscope" itemtype="http://www.schema.org/SiteNavigationElement">
<a itemprop="hasPart" href="/link1.html">Link 1</a>
<a itemprop="hasPart" href="/link2.html">Link 2</a>
<a itemprop="hasPart" href="/link3.html">Link 3</a>
</nav>
使用谷歌的结构化数据测试工具通知这些链接是SiteNavigationElement的一部分,谷歌应遵循的链接,这些项目:
Answer 7:
考虑下面的代码片段改编自网页源habd.as :
<nav itemscope itemtype="https://schema.org/SiteNavigationElement">
<meta itemprop="name" content="Main Menu">
<a itemprop="url" class="active" href="/">habd.as</a>
<a itemprop="url" href="/code/">Code</a>
<a itemprop="url" href="/post/">Posts</a>
<a itemprop="url" href="/site/">Sites</a>
<a itemprop="url" href="/talk/">Talks</a>
</nav>
<nav itemscope itemtype="https://schema.org/SiteNavigationElement">
<meta itemprop="name" content="Utility Menu">
<a itemprop="url" href="/about/">About</a>
<a itemprop="url" href="/contact/">Contact</a>
</nav>
当存在如上所示的多个导航,使用SiteNavigationElement
到组导航项目,得到使用的name
,使得分组本身可以被标记。 可以使用链接本身的内容来获得该组内个别项目的标签。
因此,你的第一个例子是,尽管断言相反更正确。
Answer 8:
OP的原题包含的代码,一个很好的例子。 一切答案做虽然...
似乎每个人都在某种程度随意扔答案...你可以使用下面的谷歌官方的工具来测试模式的微数据代码search.google.com/structured-data/testing-tool 。
如果你在运行该工具所提出的答案,你会发现,没有得到预期的结果:清单SiteNavigationElement
与名称及网址
有些人可能会争辩说,整个菜单可能会被认为是“导航元素”,但我觉得它更有意义的这个面额指定单一的导航链接。 另外,如果我们使用SiteNavigationElement
作为标记整个菜单,我们没有名字在HTML格式的网址关联的方式。
要做到这一点,你需要在每个环节由一个封装itemscope
属性,它们都需要有自己的name
和url
itemprop
(这些都是单由@大卫·哈克尼斯提到的,所以他们必须每一次出现itemprop
)
<nav>
<ul>
<li itemscope itemtype="http://schema.org/SiteNavigationElement">
<a itemprop="url" href="http://example.com/link-1">
<span itemprop="name">Link 1</span>
</a>
</li>
<li itemscope itemtype="http://schema.org/SiteNavigationElement">
<a itemprop="url" href="http://example.com/link-2">
<span itemprop="name">Link 2</span>
</a>
</li>
</ul>
</nav>
以上将在代码yeld两个不同的导航元素,每一个名称和一个URL。
注: itemprop="url"
属性使用锚点的href
属性为值
文章来源: What is the correct use of schema.org SiteNavigationElement?