Vipresh
Vipresh

Reputation: 89

Remove canonical link from Sharepoint site

We have a main public site, abcd.com, which is using SharePoint Office 365 and another replica SharePoint site using this format - abcd-public.sharepoint.com.

For some reason,

  <link rel="canonical" href="http://abcd-public.sharepoint.com:80/Pages/Home.aspx" />

shows up on every page our main public website (abcd.com). The path above changes depending on the page the user is on.

If I understand this correctly, this could be one of the reason why our site does not show up on google search result at all. If possible, we would like to reverse the behavior so the SharePoint version of the site has the canonical url = abcd.com.

or

Is there a way to completely remove the canonical url from the main website (abcd.com)? Or is there some sort of a setting that could help our site to show on google search result?

Upvotes: 0

Views: 1423

Answers (1)

Sergio
Sergio

Reputation: 74

I had the same problem and the only solution that I found is create a webpart to put in the masterpage and in the prerender event of the webpart put this lines of code:

protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        HttpContext.Current.Items["CanonicalURLWithParameters"] = "http://example.com/customurl";
    }

Sergio

Upvotes: 1

Related Questions