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)

Olllie
Shopify Partner
121 11 23

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 | Founder & Developer of autoBlogger and autoSchema

autoBlogger: Seamlessly scheduled, fully automated, AI-powered, and SEO-optimised blogging with FAQs, table of contents and other features! Start your 14-day free trial today!


autoSchema: Fully automated and continuously updated Google structured data, including duplicate data removal. Simple to install – try it now!


Discover more at autoBlogger.bot!