
- 1
I've added the following code to the List.cshtml template to try and add the canonical url for the blog:
the code works but I found out that category-name the same as CurrentCategoryName, thus the canonical is wrong.
Is there a way to retrieve the category SEName, since the plugin supports it?
@{
var CategorySename = Model.CustomProperties.ContainsKey("category-name") ? Model.CustomProperties["category-name"] : "Blog";
if (!string.IsNullOrEmpty(CategorySename) && CategorySename != "Blog")
{
var canonicalUrl = Url.RouteUrl("BlogByCategory", new { SeName = CategorySename }, Context.Request.Scheme);
NopHtml.AddCanonicalUrlParts(canonicalUrl);
}
else
{
var canonicalUrl = Url.RouteUrl("Blog", null, Context.Request.Scheme);
NopHtml.AddCanonicalUrlParts(canonicalUrl);
}
}
the code works but I found out that category-name the same as CurrentCategoryName, thus the canonical is wrong.
Is there a way to retrieve the category SEName, since the plugin supports it?