[OGP] 重複したタグTwitter Cards併記なく良い

1 min read
hiroweb developer

概要

Twitter Cards タグは、Open Graph プロトコルと同じ規則に基づいているため、Open Graph を使用している場合は、Twitter Cards タグを重複させなくても良い。

Twitter Cards プロセッサは、ページ上のタグを探す際、まず Twitter Cards のプロパティをチェックし、存在しなければ対応している Open Graph プロパティをチェックする。これにより重複したマークアップを最小限に抑えることができる。

書き方

公式リファレンスによると、下記のような形で書いても問題ない。

<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@nytimesbits" />
<meta name="twitter:creator" content="@nickbilton" />
<meta
  property="og:url"
  content="http://bits.blogs.nytimes.com/2011/12/08/a-twitter-for-my-sister/"
/>
<meta property="og:title" content="A Twitter for My Sister" />
<meta
  property="og:description"
  content="In the early days, Twitter grew so quickly that it was almost impossible to add new features because engineers spent their time trying to keep the rocket ship from stalling."
/>
<meta
  property="og:image"
  content="http://graphics8.nytimes.com/images/2011/12/08/technology/bits-newtwitter/bits-newtwitter-tmagArticle.jpg"
/>

対応表

Twitter CardsOpenGraph
twitter:descriptionog:description
twitter:titleog:title
twitter:imageog:image

参考