Liquid Snippets by ALSEL
🌐 SEO/構造化データ中級

Organization・WebSite・Product・Article構造化データ

ストア全体と個別ページ(商品・記事)の構造化データを schema.org 形式の JSON-LD で出力するスニペット。Organization タイプでショップ情報とソーシャルリンク、WebSite タイプでサイト検索、Product タイプで商品情報(価格・在庫・SKU・GS1 バーコード)、Article タイプでブログ記事メタデータを Google 検索のリッチリザルト表示に対応させる。

用途
ストア全体・商品詳細ページ・ブログ記事ページで Google 検索結果の拡張表示(商品スニペット、記事スニペット、サイトリンク検索)を狙うとき。マルチタイプ構造化データを一箇所で管理したいときに活用する。
設置場所
snippets/rich-snippets.liquid に配置し、theme.liquid の </head> 直前で `{% render 'rich-snippets' %}` で呼び出す。または、各テンプレート(product.liquid、article.liquid)内で条件分岐で呼び出してもよい。
注意点
テーマ設定でロゴ URL とソーシャルメディアリンク(Facebook、Instagram、X、TikTok など)が入力されていることが前提。Product 型の price は `divided_by: 100.00` で小数点に変換しているため、Shopify の内部価格表現(セント単位)を理解しておく。GS1 バーコード(gtin12・gtin13・gtin14)はバリアントの barcode フィールドの桁数で自動判定しているが、不正なバーコードが混在するとバリデーションエラーになるため事前にデータ検証を行う。Google Search Console の URL 検査ツールで各ページの構造化データエラーを確認し、欠落フィールド(brand、availability など)がないか定期的にチェックする。
タグ:json-ldschema-orgseorich-resultproductarticleorganization

コード

126 行 / liquid
<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Organization",
    "name": {{ shop.name | json }},
    {% if settings.logo != nil %}
      "logo": {{ settings.logo | image_url: width: 500 | prepend: "https:" | json }},
    {% endif %}
    "sameAs": [
      {{ settings.social_facebook | json }},
      {{ settings.social_instagram | json }},
      {{ settings.social_x | json }},
      {{ settings.social_tiktok | json }},
      {{ settings.social_pinterest | json }},
      {{ settings.social_snapchat | json }},
      {{ settings.social_youtube | json }},
      {{ settings.social_linkedin | json }}
    ],
    "url": {{ request.origin | append: page.url | json }}
  }
</script>

{%- if request.page_type == 'index' -%}
  {% assign potential_action_target = request.origin | append: routes.search_url | append: "?q={search_term_string}" %}
  <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "WebSite",
      "name": {{ shop.name | json }},
      "potentialAction": {
        "@type": "SearchAction",
        "target": {{ potential_action_target | json }},
        "query-input": "required name=search_term_string"
      },
      "url": {{ request.origin | append: page.url | json }}
    }
  </script>
{%- endif -%}

{%- if request.page_type == 'product' -%}
  {%- liquid
    if product.selected_or_first_available_variant.featured_media
      assign seo_media = product.selected_or_first_available_variant.featured_media
    else
      assign seo_media = product.featured_media
    endif
  -%}

  <script type="application/ld+json">
    {
      "@context": "http://schema.org/",
      "@type": "Product",
      "name": {{ product.title | json }},
      "url": {{ request.origin | append: product.url | json }},
      {% if seo_media -%}
        "image": [
          {{ seo_media | image_url: width: 1920 | prepend: "https:" | json }}
        ],
      {%- endif %}
      "description": {{ product.description | strip_html | json }},
      {% if product.selected_or_first_available_variant.sku != blank -%}
        "sku": {{ product.selected_or_first_available_variant.sku | json }},
      {%- endif %}
      "brand": {
        "@type": "Brand",
        "name": {{ product.vendor | json }}
      },
      "offers": [
        {%- for variant in product.variants -%}
          {
            "@type" : "Offer",
            {%- if variant.sku != blank -%}
              "sku": {{ variant.sku | json }},
            {%- endif -%}
            {%- if variant.barcode.size == 12 -%}
              "gtin12": {{ variant.barcode }},
            {%- endif -%}
            {%- if variant.barcode.size == 13 -%}
              "gtin13": {{ variant.barcode }},
            {%- endif -%}
            {%- if variant.barcode.size == 14 -%}
              "gtin14": {{ variant.barcode }},
            {%- endif -%}
            "availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
            "price" : {{ variant.price | divided_by: 100.00 | json }},
            "priceCurrency" : {{ cart.currency.iso_code | json }},
            "url" : {{ request.origin | append: variant.url | json }}
          }{% unless forloop.last %},{% endunless %}
        {%- endfor -%}
      ]
    }
  </script>
{%- endif -%}

{%- if request.page_type == 'article' -%}
  <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "Article",
      "articleBody": {{ article.content | strip_html | json }},
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": {{ request.origin | append: page.url | json }}
      },
      "headline": {{ article.title | json }},
      {% if article.excerpt != blank %}
        "description": {{ article.excerpt | strip_html | json }},
      {% endif %}
      {% if article.image %}
        "image": [
          {{ article | image_url: width: 1920 | prepend: "https:" | json }}
        ],
      {% endif %}
      "datePublished": {{ article.published_at | date: '%Y-%m-%dT%H:%M:%SZ' | json }},
      "dateCreated": {{ article.created_at | date: '%Y-%m-%dT%H:%M:%SZ' | json }},
      "author": {
        "@type": "Person",
        "name": {{ article.author | json }}
      },
      "publisher": {
        "@type": "Organization",
        "name": {{ shop.name | json }}
      }
    }
  </script>
{%- endif -%}

出典・ライセンス

License:
MIT

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

関連項目

🌐 SEO/構造化データ初級

サイト検索のWebSite構造化データ

ストアの検索機能を schema.org の WebSite / SearchAction 型として JSON-LD で埋め込む。Google 検索ボックス機能をサポートし、検索結果ページのURL形式を指定する。

📁 shopify-snippets·MIT·17
🌐 SEO/構造化データ初級

ストア情報のOrganization構造化データ

ストア全体の基本情報(URL、ロゴ、SNS リンク)を schema.org の Organization 型 JSON-LD として埋め込む。Google 検索結果やナレッジパネルにストア情報を表示させるための構造化データ。

📁 shopify-snippets·MIT·22
🌐 SEO/構造化データ中級

Twitter Card メタタグ

商品ページ・ブログ記事・その他ページに対応した Twitter Card メタタグを <head> に出力するスニペット。ページタイプごとに card 型を切り替え、価格・在庫・ブランドなどを表示。

📁 shopify-snippets·MIT·37
🌐 SEO/構造化データ初級

ページのOGP・Twitterカードメタタグ

ページタイトル、説明、画像、URL などから Open Graph Protocol と Twitter Card のメタタグを自動生成する。商品ページでは価格情報も追加される。

📁 ks-bootshop·MIT·39
🌐 SEO/構造化データ中級

OGメタタグ(商品・記事・ページ別)

商品ページ、ブログ記事、その他ページの種類に応じて、Facebook / Twitter などの SNS で正しく共有されるための OG メタタグを自動生成する。商品は画像・価格・在庫、記事はアイキャッチ画像、その他ページはロゴを出し分ける。

📁 shopify-snippets·MIT·40
🌐 SEO/構造化データ中級

商品ページのProduct構造化データ

商品詳細ページに schema.org の Product 型 JSON-LD を埋め込み、Google 検索のリッチリザルト(価格・在庫・バリアント)に対応させる。SKU・バーコード(GTIN12/13/14)・ブランド・説明文も含め、検索結果での表示品質を高める。

📁 shopify-snippets·MIT·133