Page 1 of 1
Home Page Canonical
Posted: Sun Sep 01, 2013 7:12 am
by kwikstand
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.
Re: Home Page Canonical
Posted: Tue Sep 03, 2013 3:28 am
by ForumsAdmin
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);
}
Re: Home Page Canonical
Posted: Thu Sep 05, 2013 7:44 am
by kwikstand
Thanks, but I just tried this and there is no change. The canaonical is still /Default.aspx
Re: Home Page Canonical
Posted: Fri Sep 06, 2013 3:13 am
by mazhar
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"))
Re: Home Page Canonical
Posted: Fri Sep 06, 2013 7:07 am
by kwikstand
Thanks Mazhar. That worked pretty well, as usual.
Thanks,
Scott Kahle