JSON-LDで構造化データマークアップ
JSON-LDとは、検索エンジンでパンくずリストや評価などのリッチスニペットを表示させるために必要な構造化データマークアップです。
JSON-LD 基本構文
基本的にjsonと同じですが、"@context": "http://schema.org/"
が最初必要な点やオブジェクトの役割を"@type": "",
で指定する点が少し変わっていると思えます。
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "",
"key": "value",
"key": [
{
"@type": "",
"key": "value",
}, {
"@type": "",
"key": "value",
}
]
}
</script>
トップページ
googleの検索結果に検索窓を表示したくない場合は「potentialAction」部を削除してください。
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://example.com/search?&q={query}",
"query-input": "required"
}
}
</script>
パンくずリスト
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement":
[
{
"@type": "ListItem",
"position": 1,
"item":
{
"@id": "https://example.com/dresses",
"name": "Dresses"
}
},
{
"@type": "ListItem",
"position": 2,
"item":
{
"@id": "https://example.com/dresses/real",
"name": "Real Dresses"
}
}
]
}
</script>
ブログ記事
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://example.com/article/"
},
"headline": "記事タイトル",
"image": {
"@type": "ImageObject",
"url": "https://example.com/thumbnail.png/",
"height": 800,
"width": 800
},
"datePublished": "2016-12-06T00:00:00+08:00",
"dateModified": "2016-12-06T00:30:00+08:00",
"author": {
"@type": "Person",
"name": "著者"
},
"publisher": {
"@type": "Organization",
"name": "サイト名",
"logo": {
"@type": "ImageObject",
"url": "https://example.com/logo.png",
"width": 600,
"height": 60
}
},
"description": "記事説明文"
}
</script>
レストラン
星や営業時間を表示できます。
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"aggregateRating": {
"@type": "AggregateRating",
"bestRating": "100",
"ratingCount": "24",
"ratingValue": "87"
},
"image": "dell-30in-lcd.jpg",
"name": "Dell UltraSharp 30\" LCD Monitor",
"offers": {
"@type": "AggregateOffer",
"highPrice": "$1495",
"lowPrice": "$1250",
"offerCount": "8",
"offers": [
{
"@type": "Offer",
"url": "save-a-lot-monitors.com/dell-30.html"
},
{
"@type": "Offer",
"url": "jondoe-gadgets.com/dell-30.html"
}
]
}
}
</script>
店舗情報
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Restaurant",
"address": {
"@type": "PostalAddress",
"addressLocality": "Sunnyvale",
"addressRegion": "CA",
"postalCode": "94086",
"streetAddress": "1901 Lemur Ave"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4",
"reviewCount": "250"
},
"name": "GreatFood",
"openingHours": [
"Mo-Sa 11:00-14:30",
"Mo-Th 17:00-21:30",
"Fr-Sa 17:00-22:00"
],
"priceRange": "$$",
"servesCuisine": [
"Middle Eastern",
"Mediterranean"
],
"telephone": "(408) 714-1489",
"url": "http://www.dishdash.com"
}
</script>
イベント
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Restaurant",
"address": {
"@type": "PostalAddress",
"addressLocality": "Sunnyvale",
"addressRegion": "CA",
"postalCode": "94086",
"streetAddress": "1901 Lemur Ave"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4",
"reviewCount": "250"
},
"name": "GreatFood",
"openingHours": [
"Mo-Sa 11:00-14:30",
"Mo-Th 17:00-21:30",
"Fr-Sa 17:00-22:00"
],
"priceRange": "$$",
"servesCuisine": [
"Middle Eastern",
"Mediterranean"
],
"telephone": "(408) 714-1489",
"url": "http://www.dishdash.com"
}
</script>