♪Get out of the rel complain, Construction time again (c) Depeche Mode

続・パンくずリストを構造化データでマークアップしてみる

前回の続き、というか、再度の構造化マークアップ案。

typeofのスコープを持たせている中でrel="home"とかを使うと、Google先生から「そんなプロパティーはない!」と怒られたorz

というあたりをなんととかできないものだろうか…。

と仕様をあらためて見直していたら、RDFa Core Initial Context

This list of predefined prefixes have been defined for RDFa as an "initial context": essentially, RDFa users can use these prefixes without having the obligation of defining the prefixes in the HTML code.

とあって、その一覧の中にschemaもあることに気づいた。

prefixの定義なしで使える、ということはつまり、もしかしてだけどvocabの指定もなしにいきなりこのprefixを使えたりするんでないか? んでもって、逆にprefixをつけておけば(prefixなしの)rel属性の値を参照しなくなったりしないだろうか?

と思いつき、パンくずを以下のようにマークアップしてみることにした。


<ol typeof="schema:BreadcrumbList">
	<li property="schema:itemListElement" typeof="schema:ListItem">
		<meta property="schema:position" content="1" />
		<meta property="schema:nextItem" content="カテゴリー" />
		<span property="schema:item" typeof="schema:Thing">
			<a href="example.com/" rel="home" property="schema:url">
				<span property="schema:name">ホーム</span>
			</a>
		</span>
	</li>
	<li property="schema:itemListElement" typeof="schema:ListItem">
		<meta property="schema:position" content="2" />
		<meta property="schema:previousItem" content="ホーム" />
		<meta property="schema:nextItem" content="サブ・カテゴリー" />
		<span property="schema:item" typeof="schema:Thing">
			<a href="example.com/category/" rel="directory" property="schema:url">
				<span property="schema:name">カテゴリー</span>
			</a>
		</span>
	</li>
	<li property="schema:itemListElement" typeof="schema:ListItem">
		<meta property="schema:position" content="3" />
		<meta property="schema:previousItem" content="カテゴリー" />
		<meta property="schema:nextItem" content="記事" />
		<span property="schema:item" typeof="schema:Thing">
			<a href="example.com/category/subcategory/" rel="directory" property="schema:url">
				<span property="schema:name">サブ・カテゴリー</span>
			</a>
		</span>
	</li>
	<li property="schema:itemListElement" typeof="schema:ListItem">
		<meta property="schema:position" content="4" />
		<meta property="schema:previousItem" content="サブ・カテゴリー" />
		<span property="schema:item" typeof="schema:Thing">
			<span property="schema:name">記事</span>
		</span>
	</li>
</ol>

そして、再度、Testing Tool — Google Developersにかけてみたところ…

問題ありません

よっしゃ、いっちょクリアw

簡単にまとめると、RDFa liteでschema.orgを使用する場合…

  • vocab="http://schema.org"は不要
  • 代わりに、typeof="schema:BreadcrumbList"property="schema:itemListElement"など、RDFaにデフォルトで定義されているschema:の接頭辞をつけて常にマークアップ
  • ちなみに、部分的にschemaのスコープから外したい場合にはtypeof=""という感じでtypeofの値を空にすればいいみたい

とすることで、HTML側であらかじめ指定してあるrel属性への参照を避けることができる。

でも、ソースはさらに冗長になるけど…

"♪Get out of the rel complain, Construction time again (c) Depeche Mode"へのTwitter上でのコメントやRT

3件のツイートがあります。

ツイート 1

ツイート 2

ツイート 3