Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link to homepage (index) of store using Shopify Liquid

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?

like image 263
Sam Avatar asked Nov 21 '25 14:11

Sam


1 Answers

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

like image 148
Jake Avatar answered Nov 24 '25 06:11

Jake



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!