cancel
Showing results for 
Search instead for 
Did you mean: 

Remove canonical url from category

SOLVED

Remove canonical url from category

I tried for products and it works fine but for categories I can't remove canonical but I can add a new one.

The problem is that in html code I find 2 different canonical urls.

I used this code in category design field:

 

<reference name="head">
    <action method="removeItem" block="head">
        <item>link_rel</item>
        <name>https://www.mysite.com/produttore/birra-menabrea</name>
    </action>
    <action method="addLinkRel" translate="title">
        <rel>canonical</rel>
        <href>https://www.mysite.com/birra-menabrea.html</href>
    </action>
</reference>

I get:

<link rel="canonical" href="https://www.mysite.com/produttore/birra-menabrea" />
<link rel="canonical" href="https://www.mysite.com/birra-menabrea.html" />

I tried also on a clean magento v1.9.3.4 installation and it doesn't work.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Remove canonical url from category

I don't think it would have stopped it from working but you don't need the block attribute on the action. 

 

It should be:

 

<reference name="head">
    <action method="removeItem">
        <type>link_rel</type>
        <name>https://www.lacompagniadelcavatappi.com/produttore/birra-menabrea</name>
     </action>
</reference>
Somebody else on the internet (https://magento.stackexchange.com/a/124290/26) seemed to have to add a second remove line too:
 
<reference name="head">
    <action method="removeItem">
        <type>link_rel</type>
        <name>https://www.lacompagniadelcavatappi.com/produttore/birra-menabrea</name>
     </action>
    <action method="removeItem">
        <type>link_rel</type>
        <name>https://www.lacompagniadelcavatappi.com/produttore/birra-menabrea?___SID=U</name>
     </action>
</reference>
----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

View solution in original post

2 REPLIES 2

Re: Remove canonical url from category

I don't think it would have stopped it from working but you don't need the block attribute on the action. 

 

It should be:

 

<reference name="head">
    <action method="removeItem">
        <type>link_rel</type>
        <name>https://www.lacompagniadelcavatappi.com/produttore/birra-menabrea</name>
     </action>
</reference>
Somebody else on the internet (https://magento.stackexchange.com/a/124290/26) seemed to have to add a second remove line too:
 
<reference name="head">
    <action method="removeItem">
        <type>link_rel</type>
        <name>https://www.lacompagniadelcavatappi.com/produttore/birra-menabrea</name>
     </action>
    <action method="removeItem">
        <type>link_rel</type>
        <name>https://www.lacompagniadelcavatappi.com/produttore/birra-menabrea?___SID=U</name>
     </action>
</reference>
----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Remove canonical url from category

Adding __SID at the end of the url removes the canonical from category page. You don't need to do this on a product page.

Many thanks for the solution.