Type: Fix / Developer Guide · Stage: Optimize · Topic: Markets / Navigation / Liquid
On this page
Quick answer
If a shopper enters a Canadian or French storefront and a navigation click sends them back to the default US language or currency, inspect the link before changing market configuration. A custom header, footer, cart drawer, search form, or AJAX script may contain a hardcoded path such as /cart or /search. Shopify Markets can use subfolders such as /en-ca/ and /fr-ca/. Use Shopify’s routes Liquid object and window.Shopify.routes.root to preserve localization context.
This is a different problem from a shopper deliberately selecting a new country. The visitor may be in the right market until one link or background request silently returns them to the store’s default path.
Why older navigation implementations break
Single-market themes commonly assume that the storefront lives at the domain root. That assumption gets embedded in header snippets, JavaScript fetch calls, predictive search, footer links, and cart-drawer redirects. Once the merchant enables a second market or language, the old path may no longer describe the correct destination.
Some older tutorials recommend pasting absolute URLs or constructing country suffixes by hand. A fixed US link can override the intended market context. A guessed suffix can break when the merchant changes subfolders, domains, or language availability. Do not try to fix localization by globally replacing /us with /ca.
Fix the link at its source
- Reproduce the exact click. Record the starting URL, language, currency, clicked element, and destination. Determine whether it happens in desktop navigation, the mobile drawer, the footer, or an AJAX flow.
- Use resource links for content. For menu-managed product, collection, page, and article links, render the menu object’s
link.url. Inspect manually entered web-address links because absolute URLs can intentionally or accidentally lead to another market. - Use the routes object for utility pages. Shopify supplies paths for the cart, search, account, and other standard destinations. Avoid literal
/cartand/searchlinks in custom code. - Fix JavaScript separately. A correct Liquid cart link does not repair an AJAX cart drawer that still fetches
/cart.jsfrom the root. - Use a localization form to change countries or languages. Navigation links and localization selectors solve different problems. Do not substitute a hardcoded redirect for a buyer’s selected localization.
Liquid example: locale-aware navigation
<nav aria-label="Store utilities">
<a href="{{ routes.root_url }}">Home</a>
<a href="{{ routes.search_url }}">Search</a>
<a href="{{ routes.cart_url }}">Cart</a>
<a href="{{ routes.account_login_url }}">Account</a>
</nav>
{% for link in linklists['main-menu'].links %}
<a href="{{ link.url }}">{{ link.title | escape }}</a>
{% endfor %}
Replace main-menu with the actual menu handle used by your theme. Menu links should remain editable through Shopify’s menu administration rather than being duplicated as hardcoded HTML in every header variation.
JavaScript example: preserve the current route root
const root = window.Shopify?.routes?.root || '/';
const response = await fetch(root + 'cart.js', {
credentials: 'same-origin'
});
if (!response.ok) throw new Error('Unable to read cart');
const cart = await response.json();
console.log(cart.currency, cart.item_count);
Shopify documents window.Shopify.routes.root as ending in a slash. Use the same approach for AJAX Cart endpoints such as cart/add.js and cart/change.js. Do not prepend another slash or guess the market code. A locale-aware path does not make an unpublished product available in every market; product availability is a separate concern.
Common misunderstanding
“The currency changed, so our currency app must be broken.” Perhaps, but compare the URL before and after the click first. A return to the primary market path is an immediate clue.
“We can build every country URL from the language code.” Language and country are not interchangeable. The same language may be available in several markets with different paths or domains.
“The desktop menu is fixed, so localization is fixed.” Not until the mobile menu, cart requests, predictive search, footer links, and account destinations have also been checked.
How to test this
- Open the primary market and two non-primary contexts, such as Canadian English and Canadian French where enabled.
- Follow top-level menu links, collection links, search, cart, and account links. Confirm the expected domain or subfolder after each click.
- Add a product through the normal form and through AJAX quick-add. Check the cart response currency and the visible cart currency.
- Repeat on mobile. Inspect network requests to identify any hardcoded root paths missed in Liquid.
- Change country with the localization selector and verify that the selection is preserved through a full product-to-cart journey.
- Repeat the regression whenever Markets domains, languages, or navigation are changed.
Sources and further reading
- Shopify Dev: Support multiple currencies and languages
- Shopify Dev: routes Liquid object
- Shopify Dev: link Liquid object
- Shopify Dev: localization Liquid object
Documentation reviewed October 20, 2026.

