Retrieving the current domain URL

kdoginator
New Member
2 0 0

Hi, 

I'm trying to use this new international domain feature on my store: https://help.shopify.com/en/manual/online-store/os/domains/managing-domains/international-domains

But there seems to be an issue with some of the urls in the theme I'm using that refer back to the primary domain, when it should be using the secondary domain url.

For example, the theme is retrieving the url of the website to make the search function work and is using {{ shop.url }} for this. It seems that {{ shop.url }} is always retrieving the primary domain url, which in this case is not correct and breaks search functionality + causes breadcrumbs to be incorrect. 

Is there a liquid object/function that can be used to retrieve the URL of this specific domain instead, and not that of the primary domain?

0 Likes
ThemuMitch
Explorer
45 11 11

Hi kdoginator,

 

It looks like you're after the routes object:

https://shopify.dev/docs/themes/liquid/reference/objects/routes

 

In this instance, you would use {{ routes.root_url }} or {{ routes.search_url }} (depending on your use case) in place of {{ shop_url }}.

 

I hope this helps.

Was your problem solved? Please mark this post as an Accepted Solution
0 Likes
kdoginator
New Member
2 0 0

Very late reply, but this doesn't work because shop.url give the actual domain like: "www.google.com", while {{ routes.root_url }} just returns "/"

0 Likes