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 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,
"handle": {},
"levels": 0,
"links": [],
"object": {},
"title": {},
"type": "page_link",
"url": "/pages/contact"
}
Was this section helpful?