03 December 2008

Dynamic Meta Tags


Meta tags are HTML or XHTML elements used to provide structured meta data about a Web page. Meta tags can be used to specify page description, keywords and any other Meta Data not provided through the other head elements and attributes.
Meta tags prove to be an important source of information for search engine's and hence for your Web pages to be properly listed in search engine results proper Search Engine Optimization is necessary.
Meta tags can be added Dynamically in ASP.NET by using following code which uses the System.Web.UI.HtmlControls class:

HtmlMeta meta = new HtmlMeta();
meta.Name = "meta-name"; //eg keywords, description
meta.Content = "content";
Page.Header.Controls.Add(meta);

In PHP we will need to echo the values in the head section of the Web page as follows:

<head>
<meta name="<?php echo $name; ?>" content="<?php echo $content; ?>" />
</head>

For more information on Meta Elements you can check out Wikipedia.

No comments: