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

Solved
JohnFederkins
Tourist
8 1 0

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
Michal_Morek
Shopify Partner
821 73 139

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

 

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
0 Likes
JohnFederkins
Tourist
8 1 0

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
Michal_Morek
Shopify Partner
821 73 139

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!

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
JohnFederkins
Tourist
8 1 0

This is an accepted solution.

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

0 Likes
Michal_Morek
Shopify Partner
821 73 139

Hi @JohnFederkins 

Hope you're having a great day!

You're welcome. Always happy to help.

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
0 Likes
Michal_Morek
Shopify Partner
821 73 139

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.

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
0 Likes