Is there a domain variable (for multi-domain shops)?

Solved
JohnFederkins
Tourist
8 1 1

I'm looking for a Liquid variable that identifies the domain name (or URL) of the current web page.
Everything I've seen so far only returns the Primary domain name.

This article seems to make use of shop.domain, but I suspect it is only useful for having the same code on multiple shops (not just multiple domains).

I've also checked out canonical_url, shop.url, page.url.   Everything just reports the primary URL.

0 Likes
Michal17
Shopify Partner
820 73 147

Hi @JohnFederkins 

Hope you're having a great day!

shop.domain
Returns the primary domain of the shop.

shop.url
Returns the full URL of a shop.

shop.permanent_domain
Returns the .myshopify.com URL of a shop.

shop.secure_url
Returns the full URL of a shop prepended by the https protocol.

 

scrnli_15_06_2021_11-49-42.png

Please hit this page to see details about this screenshot.

Useful resources:

Shopify store Domain object

 

0 Likes
JohnFederkins
Tourist
8 1 1

Hi Michael -
Thank you for your reply, I appreciate your help.  Unfortunately, those variables do not provide what I am after.
They only provide the URLs of the primary shop domain.  I'm looking for the URL of domain currently being accessed.

I've temporarily implemented something in Javascript that works using:  
currentURL = window.location.href;

Ideally, I'd like to pass this JS variable to a Liquid variable, so I can carry on with my task using liquid.
It's much cleaner that way instead of having to jump into JS scripts all the time.

In the end, the intention is to provide different presentations of the store based on the original URL.

Thanks,
John

0 Likes
Michal17
Shopify Partner
820 73 147

This is an accepted solution.

Hi @JohnFederkins 

Hope you're having a great day!

I got it. Please check request.host from the request object.

The-request-object.png

 

To get the path to the current page, check request.path from the request object

scrnli_16_06_2021_17-24-33.png

If you found this comment useful then please hit Like and Accept the Solution!

JohnFederkins
Tourist
8 1 1

This is an accepted solution.

BINGO!
request.host is what I was looking for.
Thank you so much!

0 Likes
Michal17
Shopify Partner
820 73 147

Hi @JohnFederkins 

Hope you're having a great day!

You're welcome. Always happy to help.

0 Likes
Michal17
Shopify Partner
820 73 147

This is an accepted solution.

Hi @JohnFederkins 

Please, mark the answer that helped you as an accepted solution and hit Like. This would help others in the future who have the same problem and come across this thread.

0 Likes