Liquid Snippets by ALSEL
📘 公式リファレンス🔧 リファレンス/フィルター初級

structured_data フィルター(schema.org 構造化データに変換)

商品またはブログ記事オブジェクトを schema.org の構造化データ形式に変換するフィルター。バリアントがない場合は Product 型、バリアントがある場合は ProductGroup 型として出力される。

用途
商品ページやブログ記事ページに JSON-LD を埋め込み、Google 検索結果のリッチリザルト(商品価格・在庫・記事日付など)を表示させるときに使う。
設置場所
product テンプレートまたは article テンプレートの `<head>` 内に `<script type="application/ld+json">{{ product | structured_data }}</script>` または `<script type="application/ld+json">{{ article | structured_data }}</script>` の形で記述する。
注意点
product オブジェクトの場合、バリアント有無で自動的に ProductGroup と Product が切り替わるため、手動での型指定は不要。article オブジェクトは常に Article 型で出力される。出力されるデータは article の published_at / image / author などメタフィールドの有無に依存するため、Shopify 管理画面で必須情報を埋めておくことが前提となる。
タグ:json-ldschema-orgproductarticleseo

仕様

30 行 / json
{
  "category": "format",
  "deprecated": false,
  "deprecation_reason": "",
  "description": "The `structured_data` filter can be used on the [`product`](/docs/api/liquid/objects/product) and [`article`](/docs/api/liquid/objects/article) objects.\n\nProduct objects are output as a [schema.org `Product`](https://schema.org/Product) if they have no variants, and a [`ProductGroup`](https://schema.org/ProductGroup) if they have one or more variants.\n\nArticle objects are output as a [schema.org `Article`.](https://schema.org/Article)",
  "parameters": [],
  "return_type": [
    {
      "type": "string",
      "name": "",
      "description": "",
      "array_value": ""
    }
  ],
  "examples": [
    {
      "name": "",
      "description": "",
      "syntax": "",
      "path": "/products/crocodile-tears",
      "raw_liquid": "&lt;script type=\"application/ld+json\"&gt;\n  {{ product | structured_data }}\n&lt;/script&gt;",
      "parameter": false,
      "display_type": "text",
      "show_data_tab": true
    }
  ],
  "summary": "Converts an object into a schema.org structured data format.",
  "syntax": "variable | structured_data",
  "name": "structured_data"
}

出典・ライセンス

License:
MIT

このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。

関連項目

📘 公式リファレンス🔧 リファレンス/フィルター初級

avatar フィルター(顧客アバター画像HTML生成)

顧客アバターが存在する場合、それを表示する HTML タグを生成するフィルター。customer オブジェクトに対して使用する。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

default_errors フィルター(フォーム送信エラーを日本語化)

form.errors の各エラーコードに対応する既定のエラーメッセージを自動生成するフィルター。フォーム送信時の入力値不正や必須項目空白などのエラーを言語別に出力する。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

date フィルター(日付を指定形式でフォーマット)

日付値を指定されたフォーマット文字列に従って整形する。フォーマット文字列が空の場合は元の値がそのまま返される。入力が日付に変換できない場合も元の値が返される。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

payment_terms フィルター(Shop Pay分割払いバナーを生成)

product フォームまたは cart フォームに対して使用し、Shop Pay の分割払いオプションを表示するための HTML を生成するフィルター。顧客が購入時に分割払いプランを選択できるようにする。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

abs フィルター(数値の絶対値を取得)

負の数を正の数に変換する。数値の絶対値(ゼロからの距離)を返すフィルター。

📁 theme-liquid-docs·MIT·30
📘 公式リファレンス🔧 リファレンス/フィルター初級

append フィルター(文字列の末尾に追加)

文字列の末尾に別の文字列を連結するフィルター。URL パスの結合やテキストの接尾辞追加に使う。

📁 theme-liquid-docs·MIT·30