2015-10-28 44 views
1

我試圖向我的網頁添加一些JSON-LD標記。這是我寫的JSON-LD標記的正確格式

<script type="application/ld+json"> 
{ 
"@context": "http://schema.org", 
"@type": "WebPage", 
"url": "http://www.example.com", 
"name": "Title goes here" 
} 
</script> 

^^這證實確定。很基本:-)但是,我想爲每個頁面添加一些額外的描述性屬性。

編輯:這是我想放在一起,這didnt驗證:

<script type="application/ld+json"> 
    { 
    "@context": "http://schema.org", 
    "@type": "WebPage, 
    "name": "Title goes here" 
    "description": "Description goes here" 
"significantLink":{ 
"URL": "http://example.com/page" 
"URL": "http://example.com/page2" 
"URL": "http://example.com/page3"} 
    "relatedLink": 
{ 
"URL": "http://example.com/anotherpage" 
"URL": "http://example.com/anotherpage2" 
"URL": "http://example.com/anotherpage3" 
} 
} 
</script> 

什麼會幫助我更好地理解的格式將是一個擴展案例與格式正確的額外JSON-LD特性包括在內。有人可以請解釋如何糾正我的例子,包括以下屬性?

「描述」
「關鍵字」
「similarLink」
「relatedLink」

如果有你認爲應該包括良好的標記其他標記,請註明太

+1

您是否嘗試添加這些附加屬性?如果是,請告訴我們你已經嘗試了什麼。堆棧溢出不是真正的請求示例的正確位置。 – unor

+0

schema.org文檔中有一些示例。 http://schema.org/WebPage你也許可以在這裏找到其他的例子http://stackoverflow.com/search?q=schema.org+webpage+[json-ld] – inf3rno

+0

謝謝 - 我編輯了我的帖子,包括什麼我試圖根據架構文檔早些放在一起。我找不到任何關於重要鏈接+相關鏈接的標記的示例。 – user2408290

回答

1

比如你在您的最新評論中有無效的JSON,因爲您在某些屬性值後缺少逗號。我建議使用Google Structured Data Testing Tool來驗證JSON和JSON-LD語法。

這裏的每個屬性的單個項目的示例:

<script type="application/ld+json"> 
{ 
    "@context": "http://schema.org", 
    "@type": "WebPage", 
    "name": "name of web page", 
    "description": "same content as Description meta tag", 
    "keywords": "test, example", 
    "significantLink": "http://example.com/page", 
    "relatedLink": "http://example.com/anotherpage" 
} 
</script> 

要添加多於一個signigicantLinkrelatedLink簡單地使特性陣列。如果您不想將它們連接在一起成爲一個字符串,也可以將keywords屬性作爲數組。

<script type="application/ld+json"> 
{ 
    "@context": "http://schema.org", 
    "@type": "WebPage", 
    "name": "name of web page", 
    "description": "same content as Description meta tag", 
    "keywords": ["test", "example"], 
    "significantLink": [ 
    "http://example.com/page", 
    "http://example.com/page2" 
    ], 
    "relatedLink": [ 
    "http://example.com/anotherpage", 
    "http://example.com/anotherpage2" 
    ] 
} 
</script>