190 likes | 376 Views
Building search engine friendly websites with ASP.NET 4.0. Chaitra Nagaraj Microsoft ASP.NET MVP http://chaitranagaraj@spaces.live.com . What is Search Engine Friendly?. Search Engine Friendly
E N D
Building search engine friendly websites with ASP.NET 4.0 Chaitra Nagaraj Microsoft ASP.NET MVP http://chaitranagaraj@spaces.live.com
What is Search Engine Friendly? Search Engine Friendly The term "search engine friendly" may be used to describe website designs, menus, content management systems, images, videos, shopping carts, and other elements that have been optimized for the purpose of search engine exposure. Search Engine Optimization(SEO) A definition: The modification of a web site’s build, content, and inbound linking to better position the site in the natural/un-paid results of major search engines.
Best practices for good URLs • Describe your content • Keep it short • Static is the Way • Descriptive are better than numbers • http://www.taget.com/114/cat223/ - bad way • http://www.taget.com/brand/addidas - good way • Keywords Never Hurt • Sub domains not the Answer: siteexplorer.search.yahoo.com • Fewer Folders • Hyphens separate best: Use – followed by _,+ Eg: /brands/dolce-and-gabbana/ • Stick with Conventions • Don't be Case Sensitive • Don't append extraneous data
What affects ranking? 1. On-Page Keyword specific ranking factors: - Keyword use anywhere in the title tag - Keyword use as the first word in the title tag - Keyword use the root domain name 2. On-Page Non Keyword factors: - Existense of substansive, unique content on the page - Freshness of page creation - Use of links on the page that point to other URLs on this domain - Existense of meta description tags
3. Other positive Ranking factors: - Keyword focused Anchor text from External links - External link popularity - Diversity of Link sources - Trustworthiness of the domain 4. Negative factors - Cloaking with malacious content - Link acquisition from link brokers/sellers - Link from pages to web spam sites - Cloaking by user agents - Frequent server downtime and inaccessibility
Guidelines for search friendly URLS • Create Unique, accurate page titles • Make use of the "description" meta tag • Improve the structure of your URLs • Provide one version of a URL to reach a document • Create a simple directory structure • Make your site easier to navigate • Create a Sitemap for your site • Have a useful 404 page. • Offer quality content and services • Optimize the use of images • Make effective use of robots.txt • Be aware of rel=“nofollow” for links
Search friendly Url using ASP.NET 4.0 • Use of HTML code snippets in VS 2010 • Use of DOCTYPE element • Descriptive HTML - Descriptive Title and Metadata <head runat="server"> <title>Programming meta tags in ASP.NET 4.0</title> <meta name="keywords" content="ASP.NET, ASP.NET 4.0, SEO, meta" /> <meta name="description" content= "How to use Page.MetaKeywords and Page.MetaDescription in ASP.NET" /></head> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Page.Title = "Programming meta tags in ASP.NET 4.0"; Page.MetaKeywords = "ASP.NET 4.0, meta, SEO, keywords"; Page.MetaDescription = "How to use Page.Keywords and Page.Description in ASP.NET"; } }
- Cont’d • Canonical URLs : RedirectPermanent method • void Application_BeginRequest(object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; • if (app != null) • { string domain = "www.odetocode.com"; • string host = app.Request.Url.Host.ToLower(); • string path = app.Request.Url.PathAndQuery; • if (!String.Equals(host, domain)) • { Uri newURL = new Uri(app.Request.Url.Scheme + • "://" + domain + path); • app.Context.Response.RedirectPermanent( • newURL.ToString(), endResponse: true); • } }
Cont’d • : Descriptive URL : Using ASP.NET routing • - Routing is a new feature of asp.net 4.0 • Components of Routing • RouteTable • Routing Rules • MapPageRoute used instead of PageRouteHandler • RouteURLExpressionBuilder • <asp:HyperLink ID="HyperLinkIT" runat="server" • NavigateUrl="<%$RouteUrl:RouteName=Department, Name=IT%>" Text="Dept IT" /> • RouteValueExpressionBuilder. • RouteValueParameter • <asp:SqlDataSource id=“sqlDataSource1” runat=“server” ..> • <selectparameters> • <asp:routeparameter name="Department" RouteKey="Name" /> • </selectparameters>
ASP.NET routing with Sitemap support <?xml version="1.0" encoding="utf-8" ?> <siteMapxmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNodeurl="~/" title="Home" description="Home"> <siteMapNodeurl="~/Search" title="Search" description="Search" /> <siteMapNodeurl="~/Details" title="Details" description="Details" /> </siteMapNode> </siteMap> private SiteMapNodeSiteMap_SiteMapResolve( object sender, SiteMapResolveEventArgs e ) { var routable = e.Context.CurrentHandler as IRoutablePage; if ( routable != null ) { varrc = routable.Routing.RequestContext; var route = rc.RouteData.Route; var segments = route.GetVirtualPath( rc, null ).VirtualPath.Split( '/' ); var path = "~/" + string.Join( "/", segments.Take( segments.Length - rc.RouteData.Values.Count ).ToArray() ); return SiteMap.Provider.FindSiteMapNodeFromKey( path ); } }
ASP.NET MVC based Routing for Search Friendly URLs routes.MapRoute( "ViewProduct", "products/{id}/{productName}", new { controller = "Product", action = "Detail", id = "", productName = "" } ); Route route = new Route(url, new MvcRouteHandler()){}; ..... ..... routes.Add(name, route); and in your ProductController class... public ActionResult Detail(int? id, string productName) { Product product = IProductRepository.Fetch(id); return View(product); }
Free SEO Toolkit from Microsoft • Local Government Goals for Free SEO Toolkit • Optimize site for • Increase Web site citizen traffic and usage • Determine how your web pages are displayed on third-party web sites • Help keep search engine results fresh • Decrease telephone calls and emails to ask for information that is not easily found on Web site • Good ROI on your Web investments • Free SEO Toolkit Installation • Requires Microsoft Web Platform Installer
Analyzing Free SEO Toolkit Reports • Free SEO Tool identifies pages that are branded; for example, sets of pages named “MRSC -Page Title” should be renamed “Page Title - MRSC“ since search engines put more weight on words at the beginning of page titles than words at the end of page titles • Finds broken and redirected links and shows what pages link to them; useful for domain changes and other major site re-organizations • Finds HTML errors, missing ALT tags, protocols used, improper syntax and pages that are too large • Many other categories of reports
Free SEO Toolkit Sitemap Tool Can be customized to index your site and be made available to search engines Good for dynamic pages that change frequently Lets Google/Yahoo!/Bing know how often your content changes so that it can be reindexed in a more timely manner XML format allows metadata insertion Can be set to run on a daily, weekly, monthly or yearly schedule
References • SEO friendly URL’s http://www.seomoz.org/blog/11-best-practices-for-urls http://www.4guysfromrolla.com/articles/012710-1.aspx • ASP.NET 4.0 Routing: http://chriscavanagh.wordpress.com/2009/05/19/asp-net-webform-routing-with-sitemaps/ http://www.4guysfromrolla.com/articles/012710-1.aspx • SEO Toolkit: http://weblogs.asp.net/scottgu/archive/2009/06/03/iis-search-engine-optimization-toolkit.aspx
Feedback / QnA • Your Feedback is Important! Please take a few moments to fill out our online feedback form • Use the Question Manager on LiveMeeting to ask your questions now!