📘 公式リファレンス📦 リファレンス/オブジェクト初級
link オブジェクト
リンクリストに含まれるリンク要素を表すオブジェクト。リンクの URL、タイトル、アクティブ状態、子リンクなどにアクセスできる。
用途
テーマのナビゲーションメニュー構築時に、Shopify 管理画面で設定したリンクリストをループし、各リンクの active プロパティでハイライト、子リンクの有無でドロップダウン表示を制御する。
設置場所
Liquid テンプレート内で `{{ link.title }}`、`{{ link.url }}`、`link.active`、`link.links` などの形で参照する。通常は `{% for link in linklists.メインメニュー.links %}` のようにリンクリストをループして使う。
注意点
link オブジェクトは linklist オブジェクトの links プロパティ内でのみ使用可能で、グローバルスコープではアクセスできない。active と current の区別に注意:current は URL が完全一致した場合、active は URL が一致または含まれた場合に true になる。URL パラメータはマッチ判定から除外されるため、クエリパラメータ付きのリンクでも同一 URL として扱われる。
仕様
285 行 / json{
"access": {
"global": false,
"parents": [
{
"object": "linklist",
"property": "links"
}
],
"template": []
},
"deprecated": false,
"deprecation_reason": "",
"description": "To learn about how to implement navigation in a theme, refer to [Add navigation to your theme](/themes/navigation-search/navigation).",
"properties": [
{
"deprecated": false,
"deprecation_reason": "",
"description": "A link is considered to be active if the current URL path matches, or contains, the link's [url](/docs/api/liquid/objects/link#link-url).\nFor example, if the current URL path is `/blog/potion-notions/new-potions-for-spring`, then the following link URLs\nwould be considered active:\n\n- `/blog/potion-notions/new-potions-for-spring`\n- `/blog/potion-notions`\n\n> Tip:\n> The `link.active` property is useful for menu designs that highlight when top-level navigation categories are being\n> viewed. For example, if a customer is viewing an article from the \"Potion notions\" blog, then the \"Potion notions\" link\n> is highlighted in the menu.",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the link is active. Returns `false` if not.",
"name": "active"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> URL parameters are ignored when determining a match.\n>\n> Product URLs [within the context of a collection](/docs/api/liquid/filters/within) are treated as equal to a standard product\n> URL for the same product.",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the current URL path matches the [URL](/docs/api/liquid/objects/link#link-url) of the link. Returns `false` if not.",
"name": "current"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "A link is considered to be active if the current URL path matches, or contains, the [URL](/docs/api/liquid/objects/link#link-url) of\nthe link.\n\nFor example, if the current URL path is `/blog/potion-notions/new-potions-for-spring`, then the following link URLs\nwould be considered active:\n\n- `/blog/potion-notions/new-potions-for-spring`\n- `/blog/potion-notions`",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if a link's child link is active. Returns `false` if not.",
"name": "child_active"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> URL parameters are ignored when determining a match.\n>\n> Product URLs [within the context of a collection](/docs/api/liquid/filters/within) and standard product URLs are treated\n> the same.",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if current URL path matches a link's child link [URL](/docs/api/liquid/objects/link#link-url). Returns `false` if not.",
"name": "child_current"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The [handle](/docs/api/liquid/basics#handles) of the link.",
"name": "handle"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [
{
"name": "Check the number of links",
"description": "",
"syntax": "",
"path": "/",
"raw_liquid": "{% for link in linklists.main-menu.links -%}\n {% if link.links.size > 0 -%}\n - {{ link.title }} ({{ link.links.size }} children)<br>\n {%- else -%}\n - {{ link.title }}<br>\n {%- endif %}\n{%- endfor %}",
"parameter": false,
"display_type": "text",
"show_data_tab": true
}
],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "link"
}
],
"summary": "The child links of the link.",
"name": "links"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "The object can be one of the following:\n\n- [`article`](/docs/api/liquid/objects/article)\n- [`blog`](/docs/api/liquid/objects/blog)\n- [`collection`](/docs/api/liquid/objects/collection)\n- [`metaobject`](docs/api/liquid/objects/metaobject)\n- [`page`](/docs/api/liquid/objects/page)\n- [`policy`](/docs/api/liquid/objects/policy)\n- [`product`](/docs/api/liquid/objects/product)",
"examples": [],
"return_type": [
{
"type": "untyped",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The object associated with the link.",
"name": "object"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The title of the link.",
"name": "title"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "article_link",
"description": "The link points to an article.",
"array_value": ""
},
{
"type": "string",
"name": "blog_link",
"description": "The link points to an blog.",
"array_value": ""
},
{
"type": "string",
"name": "catalog_link",
"description": "The link points to the [catalog page](https://help.shopify.com/manual/online-store/themes/customizing-themes/change-catalog-page).",
"array_value": ""
},
{
"type": "string",
"name": "collection_link",
"description": "The link points to a collection.",
"array_value": ""
},
{
"type": "string",
"name": "collections_link",
"description": "The link points to the [collection list page](/themes/architecture/templates/list-collections).",
"array_value": ""
},
{
"type": "string",
"name": "customer_account_page_link",
"description": "The link points to a [customer account page](https://shopify.dev/docs/apps/build/customer-accounts/full-page-extensions).",
"array_value": ""
},
{
"type": "string",
"name": "frontpage_link",
"description": "The link points to the home page.",
"array_value": ""
},
{
"type": "string",
"name": "http_link",
"description": "The link points to an external web page, or a product type or vendor collection.",
"array_value": ""
},
{
"type": "string",
"name": "metaobject_link",
"description": "The link points to a metaobject page.",
"array_value": ""
},
{
"type": "string",
"name": "page_link",
"description": "The link points to a [page](https://help.shopify.com/manual/online-store/themes/theme-structure/pages).",
"array_value": ""
},
{
"type": "string",
"name": "policy_link",
"description": "The link points to a [policy page](https://help.shopify.com/manual/checkout-settings/refund-privacy-tos#add-links-to-your-policies-within-pages-or-on-social-media).",
"array_value": ""
},
{
"type": "string",
"name": "product_link",
"description": "The link points to a product page.",
"array_value": ""
},
{
"type": "string",
"name": "search_link",
"description": "The link points to the search page.",
"array_value": ""
}
],
"summary": "The type of the link.",
"name": "type"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The number of nested levels under the link.",
"name": "levels"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The URL of the link.",
"name": "url"
}
],
"summary": "A link in a [menu](https://help.shopify.com/manual/online-store/menus-and-links/drop-down-menus).",
"name": "link",
"examples": [],
"json_data": {
"path": "/",
"handle": "linklists.to_a[0].links[2]",
"data_from_file": ""
},
"return_type": []
}出典・ライセンス
- Repository:
- https://github.com/Shopify/theme-liquid-docs
- 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 行