はしくれエンジニアもどきのメモ

情報系技術・哲学・デザインなどの勉強メモ・備忘録です。

構造化データschema.orgとThingタイプ

構造化データschema.orgとThingタイプ

構造化データschema.orgについてのメモ. 特に,schema.orgのThingタイプについてのメモ.

構造化データとは

構造化データとは、HTMLで書かれた情報が何を意味するのかを、 検索エンジンやその他のクローラーに理解できるようタグ付けしたものです。

blog.sakurasaku-labo.jp

とあるように, 構造化データは,人,ウェブサイト,ウェブページなどといった情報をHTMLタグ以上の情報で意味付けを行える.

例えば, ウェブページであれば,レストラン情報のページなのか,何かの商品ページなのかという情報をHTMLタグ以上に定義できる.

また,人であれば名前や住所などを定義し,ウェブサイトであればウェブサイトの名前とURLを定義し,著作権者をその人として定義し結び付けを行える.

Googleでも解説されている.

support.google.com

schema.orgとは

構造化データの仕様の1つにschema.orgがある.

公式: schema.org

日本語訳: schemaorg.biz

Schema.org vocabulary can be used with many different encodings, including RDFa, Microdata and JSON-LD. These vocabularies cover entities, relationships between entities and actions, and can easily be extended through a well-documented extension model. Over 10 million sites use Schema.org to markup their web pages and email messages. Many applications from Google, Microsoft, Pinterest, Yandex and others already use these vocabularies to power rich, extensible experiences.

Schema.orgボキャブラリは、RDFa、MicrodataJSON-LDなど、さまざまなエンコーディングで使用できます。 これらのボキャブラリは、エンティティ、エンティティとアクション間の関係をカバーし、よく文書化された拡張モデルを通じて容易に拡張できます。 1,000万を超えるサイトでは、Schema.orgを使用してWebページや電子メールメッセージをマークアップしています。 GoogleMicrosoftPinterest、Yandexなどの多くのアプリケーションは、すでに,豊富で拡張性の高いエクスペリエンスにこれらのボキャブラリを使用しています。

schema.orgのTypeとProperty

意味づけの仕方は,

  • 意味付けしたいタイプを指定し,
  • そのタイプが持っているプロパティを指定していく.

また,基本的にタイプは,継承されて定義されており, 継承元のプロパティも使用できる.

例えば, 最も基本のタイプはThingで, 他のタイプはThingを継承しており, 継承元のThingのプロパティを使える.

schema.orgの構造化データ指定方法(マークアップ方法)

主に3つ.

  • RDFa
  • microdata: > microdata は HTML タグや HTML 属性を使用してデータを定義します。
  • JSON-LD: > JSON-LD は HTML ページで JavaScript オブジェクトを使用してデータを定義します. 現在,JSON-LDが推奨されている. 次のscript構造をwebページの中の`head`, `body`など,どこでもいいので埋め込む.
    <script type="application/ld+json">
    {
    "@context" : "http://schema.org",
    "@type" : "Person",
    "name" : "cartman",
    "address" : "Japan",
    "gender": "man"
    }
    </script>
    
    JSON-LDでの指定については,以下の記事でも例が詳いく載っている. qiita.com

validator

Google構造化データ テストツール」では,Googleが推奨しているタイプについて, プロパティが設定されているかなどvalid checkができる.

入力データの形式は

プロパティの必須,推奨,Googleの独自プロパティを確認できる.

構造化データ テストツール

タイプ:Thing

基本的に,どのタイプも以下のプロパティが使用できる.

プロパティは12個.

  • `name`:Text: The name of the item. itemの名前
  • `alternateName`:Text:An alias for the item. itemの別名。
  • `url`:URL: URL of the item.itemのURL
  • `image`: ImageObject or URL: An image of the item. This can be a URL or a fully described ImageObject. itemの画像。これは、URLまたは完全に記述されたImageObjectにすることができます。
  • `description`:Text: A description of the item. itemの説明.
  • `disambiguatingDescription`:Text: A sub property of description. A short description of the item used to disambiguate from other, similar items. Information from other properties (in particular, name) may be necessary for the description to be useful for disambiguation. descriptionのサブプロパティ。 他の似たitemから曖昧さを排除するために使用されるアイテムの短い説明。 descriptionが曖昧さ除去に有用であるためには、他のプロパティ(特に名前)からの情報が必要な場合があります。
  • `mainEntityOfPage`:CreativeWork or URL: Indicates a page (or other CreativeWork) for which this thing is the main entity being described. See background notes for details. Inverse property: [mainEntity](http://schema.org/mainEntity). ページを示す,このページにより,この`thing`が記述されている主要なエンティティであるページ(または他のCreativeWork)を示します。 逆プロパティ:mainEntity. 1つのページの中に複数の定義があった場合,`mainEntityOfPage`によって,メインのコンテンツを指定できる.例えば,記事ページに, - 記事(Article)の定義 - その記事をもつWebSiteの定義 - パンクズリストの定義 の3つがあった場合,メインコンテンツは記事なので, 記事定義の中の`mainEntityOfPage`にそのページのURL指定し,メインであることを主張できる.
  • `identifier`:PropertyValue or Text or URL: The `identifier` property represents any kind of identifier for any kind of Thing, such as ISBNs, GTIN codes, UUIDs etc.Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links. See [background notes](https://schema.org/docs/datamodel.html#identifierBg) for more details. `identifier`プロパティは,あらゆる種類の`Ting`のために,あらゆる種類の識別子を表す,例えば,ISBNs, GTIN codes, UUIDs etc. Schema.org は,テキストの文字列またはURLリンクのどちらかで, これら多くの(識別子の)表現のために,専用のプロパティ(dedicated properties)を提供する. より詳しいことについては, [background notes](https://schema.org/docs/datamodel.html#identifierBg)をみてください
  • `sameAs`:URL: URL of a reference Web page that unambiguously indicates the item's identity.E.g. the URL of the item's Wikipedia page, Wikidata entry, or official website.itemの識別情報を明白に示す参照WebページのURL。 例えば,itemのWikipediaページ、Wikidataのエントリ、または公式サイトのURL。
  • `subjectOf`:CreativeWork or Event: A CreativeWork or Event about this `Thing`. Inverse property: [about](http://pending.schema.org/about). この`Thing` についての`CreativeWork`または`Event` 逆プロパティ:[about](http://pending.schema.org/about)
  • `additionalType`:URL: An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in. In RDFa syntax, it is better to use the native RDFa syntax -the 'typeof' attribute- for multiple types. Schema.org tools may have only weaker understanding of extra types, in particular those defined externally. アイテムの追加タイプ.通常、マイクロデータ構文の外部ボキャブラリから特定のタイプをより追加するために使用されます。これは,何かとthingが入っているクラスとの関係です。RDFaの構文では、複数の型に対して 'typeof'属性の元からあるRDFa構文を使用する方が良いです。Schema.orgのツールでは、余分な型、特に外部で定義された型の理解だけ,より弱いかもしれません。
  • `potentialAction`:[Action](http://schema.org/Action): Indicates a potential Action, which describes an idealized action in which this thing would play an 'object' role.潜在的なアクションを示します, これは,理想的なアクションを表す, このアクションで,この`thing`は 'object' の役割を果たす 例えば,Actionとして「検索」を設定できる. よく`WebSite`で設定される. Sitelinks Searchbox  |  Search  |  Google Developers

Googleでの必須・推奨プロパティ

特になし. 「Google構造化データ テストツール」では,何も指定しなくてもエラーが出ないので, もしかしたらGoogleは構造化データとして見ていないタイプかもしれません.

Google構造化データ テストツールでのThingタイプのチェック

JSON-LDでの指定例

<script type="application/ld+json">
{
    "@context": "http://schema.org",
     "@type": "Thing",
     "name": "名前",
     "alternateName": "別名",
     "url": "http://",
     "description":"説明",
     "image": ["http://image/image1.jpg", "http://image/image2.png"],
     "sameAs": ["http://wikipedia.com/refference1", "http://wikipedia.com/refference2"],
     "mainEntityOfPage": {
         "@type": "WebPage",
         "@id": "http://example.com/"
     }
}
</script>

mainEntityOfPageによって,このitemがそのページにおいて,メインであることを指定できる.