Liquid Snippets by ALSEL
📘 公式リファレンス📦 リファレンス/オブジェクト初級

routes オブジェクト

Liquid テンプレート内でストアの各ページ URL をハードコードせず、`routes` オブジェクトを使って参照する。多言語対応や URL フォーマットの変更に自動追従するため、リンク切れを防げる。

用途
ナビゲーションメニュー、ログインボタン、パンくずリストなど、ストア内のリンクを動的に生成するときに使用。管理画面の多言語設定が変わっても、テーマ側で URL を書き換える必要がない。
設置場所
theme.liquid やセクション・スニペット内で `{{ routes.root_url }}`、`{{ routes.account_url }}`、`{{ routes.search_url }}` などの形で参照する。ナビゲーションや CTA ボタンの href 属性値として使用するのが一般的。
注意点
`routes` はグローバルオブジェクトなので、すべてのテンプレート・セクション・スニペット内で自動的に利用可能であり、明示的なアサインは不要。新規顧客アカウント機能が有効な場合、`account_login_url` や `account_logout_url` は新規アカウントシステムへリダイレクトされるため、アナリティクスタグの遷移先が変わることを考慮する。
タグ:routesurlnavigationlinkreference

仕様

325 行 / json
{
  "access": {
    "global": true,
    "parents": [],
    "template": []
  },
  "deprecated": false,
  "deprecation_reason": "",
  "description": "Using the `routes` object instead of hardcoding URLs helps ensure that your theme supports\n[multiple languages](/themes/internationalization/multiple-currencies-languages), as well as any possible changes in URL\nformat.",
  "properties": [
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The index (home page) URL.",
      "name": "root_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [account page](https://help.shopify.com/manual/customers/customer-accounts) URL. Redirects to [customer accounts](https://help.shopify.com/en/manual/customers/customer-accounts/new-customer-accounts) when enabled.",
      "name": "account_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [account login page](/themes/architecture/templates/customers-login) URL. Redirects to [customer accounts](https://help.shopify.com/en/manual/customers/customer-accounts/new-customer-accounts) when enabled.",
      "name": "account_login_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The URL to log a customer out of their account. Redirects to [customer accounts](https://help.shopify.com/en/manual/customers/customer-accounts/new-customer-accounts) when enabled.",
      "name": "account_logout_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [password recovery page](/themes/architecture/templates/customers-reset-password) URL. Redirects to [customer accounts](https://help.shopify.com/en/manual/customers/customer-accounts/new-customer-accounts) when enabled.",
      "name": "account_recover_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [account registration page](/themes/architecture/templates/customers-register) URL.",
      "name": "account_register_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [account addresses page](/themes/architecture/templates/customers-addresses) URL. Redirects to [customer accounts](https://help.shopify.com/en/manual/customers/customer-accounts/new-customer-accounts) when enabled.",
      "name": "account_addresses_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The URL for the [customer accounts](https://help.shopify.com/en/manual/customers/customer-accounts/new-customer-accounts) profile page.",
      "name": "account_profile_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [collection list page](/themes/architecture/templates/list-collections) URL.",
      "name": "collections_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "The all-products collection is automatically generated by Shopify and contains all products in the store.",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The all-products collection page URL.",
      "name": "all_products_collection_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [search page](/themes/architecture/templates/search) URL.",
      "name": "search_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "> Tip:\n> To learn about how to support predictive search in your theme, refer to [Add predictive search to your theme](/themes/navigation-search/search/predictive-search).",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [Predictive Search API](/api/ajax/reference/predictive-search) URL.",
      "name": "predictive_search_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [cart page](/themes/architecture/templates/cart) URL.",
      "name": "cart_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The URL for the [`/cart/add` Cart API endpoint](/api/ajax/reference/cart#post-locale-cart-add-js).",
      "name": "cart_add_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The URL for the [`/cart/change` Cart API endpoint](/api/ajax/reference/cart#post-locale-cart-change-js).",
      "name": "cart_change_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The URL for the [`/cart/clear` Cart API endpoint](/api/ajax/reference/cart#post-locale-cart-clear-js).",
      "name": "cart_clear_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The URL for the [`/cart/update` Cart API endpoint](/api/ajax/reference/cart#post-locale-cart-update-js).",
      "name": "cart_update_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The [Product Recommendations API](https://shopify.dev/api/ajax/reference/product-recommendations) URL.",
      "name": "product_recommendations_url"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "[Customer accounts](https://help.shopify.com/en/manual/customers/customer-accounts/new-customer-accounts) login page. Redirects to the storefront page the customer was on before visiting the login page.",
      "name": "storefront_login_url"
    }
  ],
  "summary": "Allows you to generate standard URLs for the storefront.",
  "name": "routes",
  "examples": [],
  "json_data": {
    "path": "/",
    "handle": "routes",
    "data_from_file": ""
  },
  "return_type": []
}

出典・ライセンス

License:
MIT

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

関連項目

📘 公式リファレンス📦 リファレンス/オブジェクト初級

content_for_header オブジェクト

Shopify が必要とするスクリプト(分析・チェックアウト・言語設定など)をすべて動的に出力するオブジェクト。theme.liquid の <head> タグ内に埋め込む必須要素。

📁 theme-liquid-docs·MIT·20
📘 公式リファレンス📦 リファレンス/オブジェクト中級

metaobjects オブジェクト

ストア全体のメタオブジェクト定義にアクセスするグローバルオブジェクト。個別のメタオブジェクトはタイプとハンドルで参照でき、メタオブジェクト定義のエントリをループで反復処理できる。

📁 theme-liquid-docs·MIT·20
📘 公式リファレンス📦 リファレンス/オブジェクト初級

additional_checkout_buttons オブジェクト

PayPal Express Checkout など、オフサイト決済に対応した外部決済プロバイダーがストアに設定されているかを真偽値で返す。`content_for_additional_checkout_buttons` と組み合わせて、該当するチェックアウトボタンを条件付きで表示する。

📁 theme-liquid-docs·MIT·27
📘 公式リファレンス📦 リファレンス/オブジェクト初級

canonical_url オブジェクト

現在のページの正規 URL を取得するオブジェクト。Google などの検索エンジンに対してどのページ版が正規であるかを指定するために使用する。

📁 theme-liquid-docs·MIT·27
📘 公式リファレンス📦 リファレンス/オブジェクト初級

content_for_index オブジェクト

ホームページに表示するセクションの内容を動的に返すオブジェクト。Liquid インデックステンプレートで必ず使用する。

📁 theme-liquid-docs·MIT·27
📘 公式リファレンス📦 リファレンス/オブジェクト初級

content_for_additional_checkout_buttons オブジェクト

PayPal、Apple Pay、Google Pay など複数の決済プロバイダが有効になっているとき、その決済ボタンを HTML として出力するオブジェクト。`additional_checkout_buttons` で有無を判定したうえで、このオブジェクトで実際のボタンを表示する。

📁 theme-liquid-docs·MIT·27