skip to Main Content

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?

3

Answers


  1. Chosen as BEST ANSWER

    I figured it out, for those curious: Just link to "/". So, a link to the homepage of your site should appear as follows in your header.liquid file:

    <a href="/">Link</a>
    

  2. 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

    Login or Signup to reply.
  3. <a href="/">Link</a> This doesn’t work for multilanguage stores.

    I think better solution is: {{ routes.root_url }}

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search