Liquid, JavaScript, themes, sales channels
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.
Solved! Go to the solution
This is an accepted solution.
Hope you're having a great day!
I got it. Please check request.host from the request object.
To get the path to the current page, check request.path from the request object
If you found this comment useful then please hit Like and Accept the Solution!
This is an accepted solution.
BINGO!
request.host is what I was looking for.
Thank you so much!
This is an accepted solution.
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.
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.
Please hit this page to see details about this screenshot.
Useful resources:
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
This is an accepted solution.
Hope you're having a great day!
I got it. Please check request.host from the request object.
To get the path to the current page, check request.path from the request object
If you found this comment useful then please hit Like and Accept the Solution!
This is an accepted solution.
BINGO!
request.host is what I was looking for.
Thank you so much!
This is an accepted solution.
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.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024