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

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

beyondgrateful
Visitor
2 0 0

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!

Replies 2 (2)

SwiftfromOC
Excursionist
33 1 5

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.

- Was my answer helpful? Please hit Like or Mark as Solution
- Swift - a powerful solution that helps speed up your store site speed score and convert better.
- Want to get in touch? Contact us | Email us
- Start your FREE trial today.

ZenoPageBuilder
Shopify Partner
1052 203 225

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

<a href="/">
<img src="Your logo image url">
</a>

Hope it helps!

 

Zeno Page Builder - Build responsive & SEO-optimized Landing pages, Blog posts, Product pages and more...
Learn more at zenobuilder.com