我想通過添加schema.org WebPage詞彙表中的元素(包括麪包屑導航的語義標記)來在語義上增強我的HTML標記。根據定義,我應該使用schema.org BreadcrumbList來實現這一點。使用schema.org WebPage和data-vocabulary.org一起使用麪包屑
雖然看到Google's documentation about adding structured data for Breadcrumbs,但他們明確聲明麪包屑的schema.org標記尚不受支持。
相反,對於data-vocabulary.org Breadcrumb顯然較舊的定義應適用。這似乎是由於這個事實,即schema.org BreadcrumbList is still disputed。實際上谷歌在他們的Structured Data Testing Tool中解析schema.org BreadcrumbList標記,但不要將它用於搜索結果中的良好表示,就像他們對使用data-vocabulary.org Breadcrumb定義標註的麪包屑所做的一樣。
但是,將兩個世界結合在一起併爲網頁和麪包屑添加語義標記將會很好。最好我能想出這個樣子的(使用itemref
防止需要嵌套每個Breadcrumb
成其他):
<body itemscope itemtype="http://schema.org/WebPage">
<h1 itemprop="name">George Orwell</h1>
<p itemprop="description">Eric Arthur Blair (25 June 1903 – 21 January
1950), who used the pen name George Orwell, was an English novelist,
essayist, journalist and critic.</p>
<nav itemprop="breadcrumb">
<ul itemscope>
<li id="bc1"itemscope itemref="bc2"
itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="http://example.com/books" itemprop="url">
<span itemprop="title">Books</span>
</a> ›
</li>
<li id="bc2" itemscope itemprop="child" itemref="bc3"
itemtype="http://data-vocabulary.org/Breadcrumb">>
<a href="http://example.com/books/authors" itemprop="url">
<span itemprop="title">Authors</span>
</a> ›
</li>
<li id="bc3" itemscope itemprop="child"
itemtype="http://data-vocabulary.org/Breadcrumb">>
<a href="http://example.com/books/authors/orwell" itemprop="url">
<span itemprop="title">George Orwell</span>
</a>
</li>
</ul>
</nav>
</body>
需要在<ul>
的itemscope
屬性,以便與itemprop="child"
後續的麪包屑不解釋爲WebPage
的屬性。
當我將這段代碼放到結構化數據測試工具中時,所有數據都被識別爲我想要的,但是對於未定義的ul
項目有警告。
忽略這些錯誤安全嗎?是否有其他方法或甚至是最佳實踐來解決問題?未來防患何種情況:在網站上使用這種代碼可能會更明智嗎?