Home Page Canonical

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
kwikstand
Commodore (COMO)
Commodore (COMO)
Posts: 410
Joined: Mon Feb 19, 2007 8:12 pm
Contact:

Home Page Canonical

Post by kwikstand » Sun Sep 01, 2013 7:12 am

I just went live with Gold and have a few questions.

The home page has canonical link as "http://216.139.232.185/Default.aspx"

How can I edit change this to "www.domainname.net" ?

It has been like this all along and I don't want to lose my page authority. For example, according to MOZ "Default.aspx" has no authority at all, but the plain version has page authority of 41.
Contractor's Solutions
www. contractors-solutions.net

User avatar
ForumsAdmin
AbleCommerce Moderator
AbleCommerce Moderator
Posts: 399
Joined: Wed Mar 13, 2013 7:19 am

Re: Home Page Canonical

Post by ForumsAdmin » Tue Sep 03, 2013 3:28 am

Home page is a webpage object that you can edit in Website -> Webpages section. The URL defined there is basically the URL used as canonical URL. Unfortunately home page is a special case. You want / or empty string to be treated as the URL for home page but this will not be allowed as a valid value for URL.

This special case however can be handled easily in code. Open App_Code/PageHelper.cs. You will see code like this somewhere around line 531.

Code: Select all

string objectUrl = storeUri.Scheme + "://" + storeUri.Authority + page.ResolveUrl(catalogObject.NavigateUrl);
Update the code to something like this

Code: Select all

string objectUrl = storeUri.Scheme + "://" + storeUri.Authority;
if(catalogObject.NavigateUrl.ToLowerInvariant().Equals("default.aspx"))
{
  objectUrl = objectUrl + page.ResolveUrl("/");
}
else
{
  objectUrl = objectUrl + page.ResolveUrl(catalogObject.NavigateUrl);
}

kwikstand
Commodore (COMO)
Commodore (COMO)
Posts: 410
Joined: Mon Feb 19, 2007 8:12 pm
Contact:

Re: Home Page Canonical

Post by kwikstand » Thu Sep 05, 2013 7:44 am

Thanks, but I just tried this and there is no change. The canaonical is still /Default.aspx
Contractor's Solutions
www. contractors-solutions.net

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Home Page Canonical

Post by mazhar » Fri Sep 06, 2013 3:13 am

I think there is small problem with code posted by ForumsAdmin.

Code: Select all

if(catalogObject.NavigateUrl.ToLowerInvariant().Equals("default.aspx"))
update this statment to

Code: Select all

if (catalogObject.NavigateUrl.ToLowerInvariant().EndsWith("default.aspx"))

kwikstand
Commodore (COMO)
Commodore (COMO)
Posts: 410
Joined: Mon Feb 19, 2007 8:12 pm
Contact:

Re: Home Page Canonical

Post by kwikstand » Fri Sep 06, 2013 7:07 am

Thanks Mazhar. That worked pretty well, as usual.

Thanks,

Scott Kahle
Contractor's Solutions
www. contractors-solutions.net

Post Reply