5

I have a store with multiple custom domains. I'm trying to find what domain is currently being requested.

Domains:

somestore.myshopify.com
store.customdomain1.com
store.customdomain2.com

When a request comes into store.customdomain1.com/collections is there a variable that will tell me it's from store.customdomain1.com ?

2 Answers 2

12

It looks like Shopify added a new Request object recently. I can't find much documentation, just the one example - but it looks like it addresses your need. Use {{ request.host }} to get the current actually-requested domain.

Reference: https://help.shopify.com/en/themes/liquid/objects/request#request-host

3

I don't think this is possible with liquid. There is {{ shop.url }}, but it appears to output your store's Primary Domain (Admin > Settings > Domains) rather than the actual domain the user requested.

I think you'd have to use Javascript instead. Either document.URL or window.location.href will give you what you want. See here.

1
  • I have the same question. There is also a {{shop.domain}} variable, and I'd expected it to display the current domain, but it seems to return the same value as {{shop.url}} :(. Commented May 1, 2016 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.