Use the routes object to generate dynamic URLs for your storefront. Using it instead of hard-coded links makes sure your theme supports any change to the URL format, for example when the theme supports several languages.
The routes object has the following attributes:
routes.root_url
Returns the base URL of the shop.
{{ routes.root_url }}
/
routes.account_url
Returns the URL of the account page.
{{ routes.account_url }}
/account
routes.accountloginurl
Returns the URL of the account login page.
{{ routes.account_login_url }}
/account/login
routes.accountlogouturl
Returns the URL that logs the customer out of their account.
{{ routes.account_logout_url }}
/account/logout
routes.accountregisterurl
Returns the URL of the account registration page.
{{ routes.account_register_url }}
/account/register
routes.accountaddressesurl
Returns the URL of the page where customers manage the addresses of their account.
{{ routes.account_addresses_url }}
/account/addresses
routes.collections_url
Returns the URL of the collections page.
{{ routes.collections_url }}
/collections
routes.allproductscollection_url
Returns the URL of the collection that contains all products of the shop.
{{ routes.all_products_collection_url }}
/collections/all
routes.search_url
Returns the search URL.
{{ routes.search_url }}
/search
routes.predictivesearchurl
Returns the URL of the predictive search.
You need to pass the required query parameters of the endpoint you use.
{{ routes.predictive_search_url }}
/search/suggest
routes.cart_url
Returns the URL of the cart.
{{ routes.cart_url }}
/cart
routes.cartaddurl
Returns the URL to add items to the cart. You need to pass at least one item with variant.id or item.key.
{{ routes.cart_add_url }}
/cart/add
routes.cartchangeurl
Returns the URL to change the quantity of an item. You need to pass the item's variant.id or line_item.key.
{{ routes.cart_change_url }}
/cart/change
routes.cartclearurl
Returns the URL to clear the cart.
{{ routes.cart_clear_url }}
/cart/clear
routes.cartupdateurl
Returns the URL to update the quantity of an item. You need to pass at least one item with variant.id.
{{ routes.cart_update_url }}
/cart/update
routes.productrecommendationsurl
Returns the URL that serves product recommendations.
{{ routes.product_recommendations_url }}
/recommendations/products
More properties
VersaCommerce also provides these properties on the routes object:
| Properties | Returns |
|---|---|
account_recover_url, account_profile_url, storefront_login_url, checkout_url, gdpr_url, revocation_url |
Storefront route URLs |