I want to link the logo of my site (in my main header) to the homepage of my store. I could do so by linking to the absolute URL (e.g., https://www.example.com), but that doesn't work when I'm testing on a development server that isn't hooked up to my domain name.
I know that I can link to pages using <a href="{{ pages.example.url }}">
, where example
is the page I want to link to. But using <a href="{{ pages.index.url }}">
doesn't seem to work — I'm assuming because index
is not actually considered a page.
Is there an easy way to link to my store's homepage using a liquid tag?
You can use {{ shop.url }}
as listed on this variable cheat sheet and in the Shopify developer reference.
Returns the full URL of a shop. http://johns-apparel.com
<a href="{{ shop.url }}">Homepage</a>
You also have the option of using the secure version {{ shop.secure_url }}
Returns the full URL of a shop prepended by the https protocol. https://johns-apparel.com
<a href="{{ shop.secure_url }}">Homepage</a>
I also found in a quick test that it will also return the preview URL when previewing an unpublished page e.g. k29ijan0ye0r5g7k-51325174.shopifypreview.com