The routes object

You can use the routes object to generate dynamic URLs to your storefront. By using them instead of hardcoded links, you can make sure your theme supports any changes to the URL format. For example, you can use the routes object to support multiple languages in your theme.

The routes object has the following attributes:

routes.root_url

Returns the base URL of the shop.

routes.account_url

Returns the URL for the account page.

routes.account_login_url

Returns the URL for the account login page.

routes.account_logout_url

Returns the URL to log the customer out of their account.

routes.account_register_url

Returns the URL for the account registration page.

routes.account_addresses_url

Returns the URL for the page where the customer can manage the addresses associated with their account.

routes.collections_url

Returns the URL for the collections page.

routes.all_products_collection_url

Returns the URL for the collection that contains all of the products in the shop.

routes.search_url

Returns the search URL.

routes.predictive_search_url

Returns the predictive search URL.

You need to specify the required query parameters for the endpoint you're using. To learn more, refer to the Predictive Search API.

routes.cart_url

Returns the cart URL.

routes.cart_add_url

Returns the URL that accepts items to be added to a cart. You must specify at least one item using the item's variant.id or item.key. For more information, refer to the Ajax Cart API reference.

routes.cart_change_url

Returns the URL that allows you to change the quantity of an item. You must specify the item's variant.id or line_item.key. For more information, refer to the Ajax Cart API reference.

routes.cart_clear_url

Returns the URL that allows you to clear the cart.

routes.cart_update_url

Returns the URL that allows you to update the quantity of an item. You must specify at least one item using the item's variant.id. For more information, refer to the Ajax Cart API reference.

routes.product_recommendations_url

Returns the URL that serves product recommendations.