Code to put a homepage link on my logo in the header

Hi, I have a custom header and a theme outside of shopify, hence the default feature of clicking the logo to get redirected to the homepage is not there. I know that it has to be done with the coding method.

Can someone please help me with code and also where exactly should I put?

Thanks in advance!

Hi @beyondgrateful ,

You can try the following steps to make your logo redirect to Homepage when clicking:

  • In Shopify admin, go to Online Store > Themes > Edit code

  • In the header.liquid file, you can insert the below code:

<script>
  $(document).ready(function() {
    // Get the logo element
    var logo = $("#logo");

    // When the logo is clicked, redirect to the homepage
    logo.click(function() {
      window.location = "/";
    });
  });
</script>
  • Save your changes and check your store front to see if it works.

Hope this can help.

You should find your logo image inside the file header.liquid (or similar) and adjust the code like this


Hope it helps!