回帖总数:
78
业力:
964
注册日期:
2010/3/26
位置:
United Kingdom
Google Webmaster tools complains of dozens of web pages which have duplicate meta descriptions. Currently the following pages output the default meta description set in admin: Configuration > Settings > General And Miscellaneous Settings > SEO Settings ~\Presentation\Nop.Web\Views\Catalog\ProductsByTag.cshtml ~\Presentation\Nop.Web\Views\Catalog\RecentlyViewedProducts.cshtml ~\Presentation\Nop.Web\Views\Catalog\RecentlyAddedProducts.cshtml ~\Presentation\Nop.Web\Views\Catalog\CompareProducts.cshtml ~\Presentation\Nop.Web\Views\Customer\Login.cshtml I can see the <meta name="description" content="@(Html.NopMetaDescription())" /> in ~\Presentation\Nop.Web\Views\Shared\_Root.cshtml\_Root.cshtml Ideally I would like to overload this in the relevant .cshtml files as above and leave the rest of the .cshtml files alone. Does anyone know how I should go about controlling the meta descriptions tag output on these pages?
回帖总数:
16619
业力:
155940
注册日期:
2008/10/22
位置:
Armenia
1. Open an appropriate cshtml file 2. Use "AddTitleParts", "AddMetaDescriptionParts", and "AddMetaKeywordParts" extensions method. P.S. Have a look at \Views\Catalog\CategoryTemplate.ProductsInGridOrLines.cshtml file to get an idea
回帖总数:
78
业力:
964
注册日期:
2010/3/26
位置:
United Kingdom
Thanks a.m. - works perfectly! Below is a fix that I think should be included in the next release. Simple SEO URL Encode that fixes spaces, ampersands, forward slashes etc. in product tags. CREATE New Class file ~\Presentation\Nop.Web\Extensions\SeoUrlEncodeExtension.cs START New Class using System; using System.Text; using System.Web.Mvc; using Nop.Core; using Nop.Core.Infrastructure; namespace Nop.Web.Extensions { //LFW 15-06-2012 SEO URL Product Tags //SOURCE: http://www.dominicpettifer.co.uk/Blog/34/asp-net-mvc-and-clean-seo-friendly-urls public static class SeoUrlEncodeExtension { public static string ToSeoUrl(string stringToEncode) { stringToEncode = (stringToEncode ?? "").Trim().ToLower(); StringBuilder url = new StringBuilder(); foreach (char ch in stringToEncode) { switch (ch) { case ' ': url.Append('-'); break; case '&': url.Append("and"); break; case '\'': break; default: if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z')) { url.Append(ch); } else { url.Append('-'); } break; } } return url.ToString(); } } } END New Class MODEL ADD SeoUrlName property to ProductTagModel class //LFW 15-06-2012 SEO URL Product Tags public string SeoUrlName { get; set; } ~\Presentation\Nop.Web\Models\Catalog\ProductTagModel.cs CONTROLLER ADD line below 'Name = x.Name,' to ProductTagModel loop within public ActionResult ProductTags(int productId) within CatalogController class SeoUrlName = SeoUrlEncodeExtension.ToSeoUrl(x.Name), //LFW 15-06-2012 SEO URL Product Tags ~\Presentation\Nop.Web\Controllers\CatalogController.cs ADD line below 'Name = tag.Name,' to ProductTagModel loop within public ActionResult PopularProductTags() within CatalogController class SeoUrlName = SeoUrlEncodeExtension.ToSeoUrl(tag.Name), //LFW 15-06-2012 SEO URL Product Tags ~\Presentation\Nop.Web\Controllers\CatalogController.cs VIEWS CHANGE Name to SeoUrlName in ProductTags view <a href="@Url.RouteUrl("ProductsByTag", new { productTagId = Model[i].Id, SeName = Model[i].SeoUrlName })" class="producttag"> ~\Presentation\Nop.Web\Views\Catalog\ProductTags.cshtml CHANGE Name to SeoUrlName in PopularProductTags view <li><a href="@Url.RouteUrl("ProductsByTag", new { productTagId = item.Id, SeName = item.SeoUrlName })" style="font-size:@(Model.GetFontSize(item))%;">@item.Name</a> ~\Presentation\Nop.Web\Views\Catalog\PopularProductTags.cshtml
回帖总数:
16619
业力:
155940
注册日期:
2008/10/22
位置:
Armenia
They're removed. Have a look at \Libraries\Nop.Services\Seo\SeoExtensions.cs file, GetSeName(string name, bool convertNonWesternChars, bool allowUnicodeCharsInUrls, bool urlEncode = false) method for more info