Custom canonical link for specific products and categories

Post By:user_3446 | Reply

 

I am trying to figure our a way of overiding Magento’s default canonical link for product and category pages using the “Custom Layout Update” field.  This is what I have so far but it is not working.  Can anybody let me know whether this is possible and what I am doing wrong?

Thanks

<action method="removeItem" block="head">
    <
item>link_rel</item>
    <
name>{product url}</name>
</
action>
<
action method="addLinkRel" block="head">
    <
link>link_rel</link>
</
action>

user_3449Tue, 09 Jul 2013

 

Hi MattyGo
Please write here how you modified the meta header to display the custom attribute as a canonical tag for each product.
What is your code and where you placed this code?

Thanks in advance !

user_3446Sun, 30 Jun 2013

 

Hi Matt,

I am using 1.7.0.02 too.  I ended up disabling canonical links in Magento Config.  I then set up a custom attribute which I applied to every product so I can set the canonical link I wanted for each product.  I could then set the same canonical link for products with different colour variants.  I then modified the meta header to display the custom attribute as a canonical tag for each product.  Very long winded but seems to do the trick.

Matt

user_3448Sun, 30 Jun 2013

 

Hi,
Anyone had any success with this? I to am unable to remove existing canonical URL.
Using 1.7.0.2. Could it be that in the new versions, magento uses a different method to create canonical links? Might therefore need a different piece of code to remove it?
I can’t find the code that creates the canonical link to see how it does it.
Anyone know where to find it?
Thanks
Matt

user_3446Sat, 16 Mar 2013

 

Hi Shaughn,

I have a bunch of simple products that are colour variants of a main product.  I do not want to merge them into a configurable product but I do not want to avoid being penalised for duplicate content by canocolizing them to a main “parent” product.

I actually posted this query in another forum and was told that the following should them.  It just doesn’t work for me though and whilst I can get the new link added I just cannot get the existing link removed so end up with canonical links on the page.

<reference name="head">

<
action method="removeItem">
<
type>link_rel</type>
<
name>http://www.existingcanonicallink.html</name>
</action>

<
action method="addLinkRel">
<
rel>canonical</rel>
<
href>http://www.yoururl.com/new-url.html</href>
</action>
</
reference>

user_3447Sat, 16 Mar 2013

 

Why would you want to set custom canonical links for products and categories?

You know there are modules like http://www.magentocommerce.com/magento-connect/canonical-url-for-magento.html that will help improve SEO,etc for this.

Else there must be a specific reason?

user_3446Sat, 16 Mar 2013

 

OK, I figured out I can add a custom canonical link for a product in the custom layout update field by adding the following. 

<reference name="head">
    <
action method="addLinkRel" translate="title">
      <
rel>canonical</rel>
      <
href>http://www.example.com/page.html</href>
    
</action>
  </
reference>

Now I could disable magento’s canonical link for product pages in the config and apply this xml update to every product but since I have hundred’s of products and only want to change a handful I am looking for a way of changing the xml code above so that it first removes the existing Magento generated canonical link.  I figure I need to use the removeitem action first but I just cannot figure out how to apply it.  If anyone could help I would be eternally grateful because I have been pulling my hair out since yesterday

Thank You

`Reply Or Comment!
Please LogIn to Reply!