Skip to main content

link

A link in a menu.

To learn about how to implement navigation in a theme, refer to Add navigation to your theme.

Properties

Returns true if the link is active. Returns false if not.

A link is considered to be active if the current URL path matches, or contains, the link's url. For example, if the current URL path is /blog/potion-notions/new-potions-for-spring, then the following link URLs would be considered active:

  • /blog/potion-notions/new-potions-for-spring
  • /blog/potion-notions
Tip

The link.active property is useful for menu designs that highlight when top-level navigation categories are being viewed. For example, if a customer is viewing an article from the "Potion notions" blog, then the "Potion notions" link is highlighted in the menu.

Returns true if a link's child link is active. Returns false if not.

A link is considered to be active if the current URL path matches, or contains, the URL of the link.

For example, if the current URL path is /blog/potion-notions/new-potions-for-spring, then the following link URLs would be considered active:

  • /blog/potion-notions/new-potions-for-spring
  • /blog/potion-notions

Returns true if current URL path matches a link's child link URL. Returns false if not.

Note

URL parameters are ignored when determining a match.

Product URLs within the context of a collection and standard product URLs are treated the same.

Returns true if the current URL path matches the URL of the link. Returns false if not.

Note

URL parameters are ignored when determining a match.

Product URLs within the context of a collection are treated as equal to a standard product URL for the same product.

The "Your Privacy Choices" opt-out icon (an <img>) for the data-sale opt-out link, or nil for any other link.

When a shop enables data-sale opt-out, Shopify automatically adds an opt-out link to the storefront, shown to buyers as "Your Privacy Choices". US state privacy laws (such as California's CCPA/CPRA) require the official "Your Privacy Choices" icon to appear next to that link. This attribute returns that icon for the opt-out link, and nil for every other link.

Render it next to {{ link.title }}, checking for it first so other links are unaffected:

{{ link.title }}{% if link.data_sharing_opt_out_icon %}{{ link.data_sharing_opt_out_icon }}{% endif %}

See Customer privacy settings.

The handle of the link.

The number of nested levels under the link.

The child links of the link.

Example
Check the number of links
{% for link in linklists.main-menu.links -%}
{% if link.links.size > 0 -%}
- {{ link.title }} ({{ link.links.size }} children)<br>
{%- else -%}
- {{ link.title }}<br>
{%- endif %}
{%- endfor %}

Output

- Home<br>
- Catalog (2 children)<br>
- Contact<br>

The object associated with the link.

The object can be one of the following:

The title of the link.

The type of the link.

Possible valuesDescription
article_linkThe link points to an article.
blog_linkThe link points to an blog.
catalog_linkThe link points to the catalog page.
collection_linkThe link points to a collection.
collections_linkThe link points to the collection list page.
customer_account_page_linkThe link points to a customer account page.
frontpage_linkThe link points to the home page.
http_linkThe link points to an external web page, or a product type or vendor collection.
metaobject_linkThe link points to a metaobject page.
page_linkThe link points to a page.
policy_linkThe link points to a policy page.
product_linkThe link points to a product page.
search_linkThe link points to the search page.

The URL of the link.

{
"active": false,
"child_active": false,
"child_current": false,
"current": false,
"data_sharing_opt_out_icon": null,
"handle": {},
"levels": 0,
"links": [],
"object": {},
"title": {},
"type": "page_link",
"url": "/pages/contact"
}
Was this section helpful?