I added the following tag to _Layout.cshtml file of my staging site:

<link rel="canonical" href="@Request.Url.AbsoluteUri">

For the most part it does return a valid link for every page on the website, but the links look nothing like the links that are normally displayed when navigating the page. For exampl:


Returns as this:

Is there a way to have it return the URL as displayed to the user? Would this even be detrimental to SEO as far as how the Canonical tag is used by search engines/crawlers? 

Has anybody ever solved this problem for all pages on an ASPDNSF 10.x website? Moz Pro is currently reporting over 5.5K MetaData issues of "Missing Canonical Tag" on my website and I would like to clear those out. Any ideas?

in MultiStore by (145 points)

1 Answer

+1 vote
Yes it is possible to have add canonical tags as your example code shows.

If you want to have the same canonical url be the the same as what the user and navagation shows then try the code below:

<link rel="canonical" href="http://@Request.Url.Host@CommonLogic.GetThisPageName(true)" />

As for would it be detrimental to have the canonical tag is somewhat subjective. Since canonical is meant to be way try and state two pages are the same content wise to search engines. That way search engines don't ding you ranking for duplicate content. I do know Moz likes to suggest this tag for every page no matter what so that is why you see so many pages reporting in Moz.
by (5k points)