[ライブドアブログ] 構造化データ
Published
『ライブドアブログ』で構造化データに対応させる方法。
Schema.orgに基づく構造化データをJSON-LD形式で実装。
仕様
掲載するコードは次の仕様に基づいている。
- Schema.orgに基づき、JSON-LD形式で実装。
- Schema.orgのプロパティについて、livedoor Blogの仕様上の問題から取得できない値があるため、それについては対応していない。(テストツールなどでエラーとなる場合がある)
- デザインテンプレートによっては構造化データがHTMLタグにマークアップされている場合がある。この場合、デザインテンプレート側のマークアップを削除する必要がある。
トップページ
livedoor Blogのトップページを構造化データに対応させる場合について。
次のコードをトップページのHTMLにある</body>の前に記述する。
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Blog",
"name": "<$BlogTitle ESCAPE$>",
<IfBlogDescription>
"description": "<$BlogDescription ESCAPE$><UnlessIsFirstPage> (Page <$PageNumber$>)</UnlessIsFirstPage>",
</IfBlogDescription>
"url": "<$BlogUrl$><UnlessIsFirstPage>?p=<$PageNumber$></UnlessIsFirstPage>"
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "<$BlogTitle ESCAPE$><UnlessIsFirstPage> (Page <$PageNumber$>)</UnlessIsFirstPage>",
"item": "<$BlogUrl$><UnlessIsFirstPage>?p=<$PageNumber$></UnlessIsFirstPage>"
}
]
}
</script>
出力している構造化データは次の通り。
- ブログのタイトル。
- ブログの説明。説明がない場合は出力しない。
- ブログのURL。2ページ目以降の場合はページ数も出力。
- パンくずリスト。
個別記事ページ
livedoor Blogの個別記事ページを構造化データに対応させる場合について。
次のコードを個別記事ページのHTMLにある</body>の前に記述する。
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "<$ArticleTitle ESCAPE$>",
"description": "<$ArticleDescription ESCAPE$>",
"url": "<$ArticlePermalink$>",
"mainEntityOfPage": "<$ArticlePermalink$>",
"datePublished": "<$ArticleDateISO8601$>",
<IfArticleFirstImage>
"image": {
"@type": "ImageObject",
"url": "<$ArticleFirstImage$>",
"width": "auto",
"height": "auto"
},
</IfArticleFirstImage>
"author": {
"@type": "Person",
"name": "<$ArticleAuthorNickname$>"
},
"publisher": {
"@type": "Organization",
"name": "<$BlogTitle ESCAPE$>"
}
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "<$BlogTitle ESCAPE$>",
"item": "<$BlogUrl$>"
},
<IfArticleCategory1>
<IfParentCategory1>
{
"@type": "ListItem",
"position": 2,
"name": "<$ParentCategory1Name$>",
"item": "<$ParentCategory1Url$>"
},
</IfParentCategory1>
{
"@type": "ListItem",
"position": <IfParentCategory1>3</IfParentCategory1><UnlessParentCategory1>2</UnlessParentCategory1>,
"name": "<$ArticleCategory1$>",
"item": "<$ArticleCategory1Url$>"
},
</IfArticleCategory1>
{
"@type": "ListItem",
"position": <IfArticleCategory1><IfParentCategory1>4</IfParentCategory1><UnlessParentCategory1>3</UnlessParentCategory1></IfArticleCategory1><UnlessArticleCategory1>2</UnlessArticleCategory1>,
"name": "<$ArticleTitle ESCAPE$>",
"item": "<$ArticlePermalink$>"
}
]
}
</script>
出力している構造化データは次の通り。
- 記事のタイトル。
- 記事の概要。
- 記事のURL。
- 記事の投稿日時。
- 記事の見出し画像。見出し画像がない場合は出力しない。
- 記事の投稿者。
- 記事が投稿されたサイト名(=ブログのタイトル)。
- 次の仕様に基づくパンくずリスト。
- 親子関係のあるカテゴリーが設定されている場合、親→子の順に出力。
- カテゴリーが設定されていない場合はカテゴリー部分を出力しない。
- 複数のカテゴリーを設定している場合には対応していない。
カテゴリアーカイブ
livedoor Blogのカテゴリアーカイブを構造化データに対応させる場合について。
次のコードをカテゴリアーカイブのHTMLにある</body>の前に記述する。
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Blog",
"name": "<$CategoryName ESCAPE$><UnlessIsFirstPage> (Page <$PageNumber$>)</UnlessIsFirstPage>",
"url": "<$CategoryUrl$><UnlessIsFirstPage>?p=<$PageNumber$></UnlessIsFirstPage>"
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "<$BlogTitle ESCAPE$>",
"item": "<$BlogUrl$>"
},
<IfHasParentCategory>
{
"@type": "ListItem",
"position": 2,
"name": "<$ParentCategoryName ESCAPE$>",
"item": "<$ParentCategoryUrl$>"
},
</IfHasParentCategory>
{
"@type": "ListItem",
"position": <IfHasParentCategory>3</IfHasParentCategory><UnlessHasParentCategory>2</UnlessHasParentCategory>,
"name": "<$CategoryName ESCAPE$><UnlessIsFirstPage> (Page <$PageNumber$>)</UnlessIsFirstPage>",
"item": "<$CategoryUrl$><UnlessIsFirstPage>?p=<$PageNumber$></UnlessIsFirstPage>"
}
]
}
</script>
出力している構造化データは次の通り。
- カテゴリー名。
- カテゴリーページのURL。2ページ目以降の場合はページ数も出力。
- パンくずリスト。親子関係のあるカテゴリーの子ページの場合、親→子の順に出力。
月別アーカイブ
livedoor Blogの月別アーカイブを構造化データに対応させる場合について。
次のコードを月別アーカイブのHTMLにある</body>の前に記述する。
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Blog",
"name": "<$MonthLabel$><UnlessIsFirstPage> (Page <$PageNumber$>)</UnlessIsFirstPage>",
"url": "<$CurrentUrl$><UnlessIsFirstPage>?p=<$PageNumber$></UnlessIsFirstPage>"
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "<$BlogTitle ESCAPE$>",
"item": "<$BlogUrl$>"
},
{
"@type": "ListItem",
"position": 2,
"name": "<$MonthLabel$><UnlessIsFirstPage> (Page <$PageNumber$>)</UnlessIsFirstPage>",
"item": "<$CurrentUrl$><UnlessIsFirstPage>?p=<$PageNumber$></UnlessIsFirstPage>"
}
]
}
</script>
出力している構造化データは次の通り。
- アーカイブ名。
- アーカイブページのURL。2ページ目以降の場合はページ数も出力。
- パンくずリスト。