2015-03-25 77 views
1

我想通過添加schema.org WebPage詞彙表中的元素(包括麪包屑導航的語義標記)來在語義上增強我的HTML標記。根據定義,我應該使用schema.org BreadcrumbList來實現這一點。使用schema.org WebPage和data-vocabulary.org一起使用麪包屑

雖然看到Google's documentation about adding structured data for Breadcrumbs,但他們明確聲明麪包屑的schema.org標記尚不受支持。

Google statement about that they don't support breadcrumb markup with schema.org yet

相反,對於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項目有警告。

忽略這些錯誤安全嗎?是否有其他方法或甚至是最佳實踐來解決問題?未來防患何種情況:在網站上使用這種代碼可能會更明智嗎?

回答

1

測試您的標記時,Google’s Testing Tool似乎沒有報告任何錯誤或警告。它對每個項目都說「一切順利」。

您對Microdata的使用是有效的。您正在添加一個沒有類型的項目,該項目沒有任何內容(因爲沒有添加任何屬性)。

使用Schema.org的breadcrumb property似乎是合適的,因爲其預期類型之一是文本。所以Schema.org消費者會只提取中的子項,沒有URL的文本內容:

圖書>>作者>>喬治·奧威爾


我不認爲linked issue是谷歌不支持Schema.org的BreadcrumbList的原因:該問題是從2012年開始的,但BreadcrumbList類型僅在幾個月前(2014-12-11)到Schema.org的類型爲added
這個問題是關於使用breadcrumb沒有類型(當時不存在)的屬性,這是不理想的,因爲這不允許爲每個麪包屑(例如,它的URL)指定元數據。


面向未來的方式是使用詞彙的麪包屑。 Microdata語法使得這hard/impossible,但RDFa語法允許這(但是,Data-Vocabulary.org奇怪的要求,麪包屑必須嵌套可能需要標記更改)。