Adding canonical tag only to the homepage?

Adding canonical tag only to the homepage?

chaweng2012
Visitor
1 0 0

Hello,

 

I was wondering if anyone can help. I need to change the homepage ONLY to refer to another page (a collections page) on my site, as the homepage is cannabalising the ranking and the collections page is the preferred page.


Is there any way of editing the html so just the canonical link on the homepage is updated (to direct to the product page?)


Many thanks!

Reply 1 (1)

autoBlogger-Oll
Shopify Partner
49 2 8

Hey @chaweng2012 ,

This should be the code you need! Simply add it near the top of your theme.liquid file:

 

 

 

{% if template == 'index' %}
  <link rel="canonical" href="https://www.AddYourUrlHere.com" />
{% endif %}

 

 

 

If this resolves your issue, please consider marking the answer as helpful or accepted!

Ollie | Owner & Developer of autoBlogger

autoBlogger — Set it and forget it! SEO optimised and powered by AI for effortless blogging. Start your 14-day free trial today!