Sunday, August 17, 2008

ASP.NET - Master pages and Search Engine Optimization:

We all know that asp.net have simplified our life with the introduction of master pages. but what about the Search engine optimization?

How do we handle that. Here are few tips for you to make your asp.net site Search engine friendly..

1. TITLE tags.
First important factor that affects your Page rank is your page's title. If you use the title tag on the master page and ignore the title attribute on child page's PAGE directive, Google bot will think all your pages are same and it will either reduce your page rank or will ignore it.


So always use the Child page's TITLE Attribute. There are multiple ways you can archive this,

1. From ASPX Page:

VB.NET :



<%@ Page Language="VB" MasterPageFile="~/Default.master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="ezSmartAds.Home" Title="Website Promotion -Improve ROI" %>

C# :

protected void Page_Load(object sender, System.EventArgs e)
{
    this.Page.Title = "Website Promotion -Improve ROI";
}

VB.NET:



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    Me.Page.Title = "Website Promotion -Improve ROI"\
End Sub

2. META Tags:


Second important factor is your Meta tags. When users search's on a search engine, Meta description is the one which encourages your users to click on your site.



Here is the explanation from Google on Meta Description:


"Differentiate the descriptions for different pages. Using identical or similar descriptions on every page of a site isn't very helpful when individual pages appear in the web results. In these cases we're less likely to display the boilerplate text. Wherever possible, create descriptions that accurately describe the specific page. Use site-level descriptions on the main home page or other aggregation pages, and use page-level descriptions everywhere else. If you don't have time to create a description for every single page, try to prioritize your content: At the very least, create a description for the critical URLs like your home page and popular pages."

Here is the sample code to add meta tags from code behind.

From Code behind:

VB.NET :


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  Dim metaTagAuthor As HtmlMeta = New HtmlMeta
  Dim metaTagKeywords As HtmlMeta = New HtmlMeta
  Dim metaTagDescription As HtmlMeta = New HtmlMeta
  metaTagAuthor.Name = "Author"
  metaTagAuthor.Content = "Your Name" 'Add your name here
  metaTagKeywords.Name = "Keywords"
  metaTagKeywords.Content = "" 'Add all your keywords here
  metaTagDescription.Name = "Description"
  metaTagDescription.Content = "" 'Add you webpage's description here
  Me.Page.Header.Controls.Add(metaTagAuthor)
  Me.Page.Header.Controls.Add(metaTagKeywords)
  Me.Page.Header.Controls.Add(metaTagDescription)
End Sub


C#:



protected void Page_Load(object sender, System.EventArgs e)
{
  HtmlMeta metaTagAuthor = new HtmlMeta();
  HtmlMeta metaTagKeywords = new HtmlMeta();
  HtmlMeta metaTagDescription = new HtmlMeta();
  metaTagAuthor.Name = "Author";
  metaTagAuthor.Content = "Your Name"; //Add your name here
  metaTagKeywords.Name = "Keywords";
  metaTagKeywords.Content = ""; //Add all your keywords here
  metaTagDescription.Name = "Description";
  metaTagDescription.Content = "";//Add you webpage's description here
  this.Page.Header.Controls.Add(metaTagKeywords);
  this.Page.Header.Controls.Add(metaTagDescription);
}

Hope you find this article useful. I have implemented the same for one of our websites www.ezsmartads.com



Thanks!

2 comments:

  1. your site is very nice ...
    this is very helpful and attractive.
    visit for asp.net help asp.net help

    ReplyDelete