how to add unique meta tags to each content page/

B

bashetty

Well its a strange problem i have, some of you might already faced it
and have a solution. I have to maintain a set of unique "search key
words" in meta tags for each content page in my site. With master
paging , i guess i can only have <head> tag in my MasterPage. Can any
one let me know how to resovle this issue?
 
B

bruce barker

add a SearchKeys property to your master page which your other pages can
set and have the master render the proper meta tag.

-- bruce (sqlwork.com)
 
C

Cowboy \(Gregory A. Beamer\)

Add using code behind. Page.Header opens up a whole new world when setting
items in the header portion of the master page. :)

Example for changing title of page (in Page_Load, etc.)

Page.Header.Title = "Some title";

You can also set up meta tags, like so

HtmlMeta metaTag = new HtmlMeta();
metaTag.HttpEquiv = "";
metaTag.Content = "";

Good luck!

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
 
U

ua

I stored the metadata of each file in a database and used the master
record page to add the appropriate scripts to the page like this.

// retrieve and set the metadata
TempDataSetTableAdapters.TWeb_PageMetaDataTableAdapter adpt =
new
TreborSetTableAdapters.TWeb_PageMetaDataTableAdapter();
TempDataSet.TWeb_PageMetaDataDataTable pmdDT =
adpt.GetPageMetaDataByPageURL(Request.AppRelativeCurrentExecutionFilePath.ToLower());

// if we didn't find a record from the database retrieve the
general one
if (pmdDT.Count <= 0)
{
pmdDT = adpt.GetPageMetaDataByPageURL("general");
}

// if we have a record for meta data, create the tags
if (pmdDT.Count > 0)
{
// Render: <meta name="keywords" content="some words" />
HtmlMeta keywords = new HtmlMeta();
keywords.Name = "keywords";
keywords.Content = pmdDT[0].keywords;
this.Page.Header.Controls.Add(keywords);

// Render: <meta name="robots" content="noindex" />
HtmlMeta robots = new HtmlMeta();
robots.Name = "robots";
robots.Content = pmdDT[0].robots;
this.Page.Header.Controls.Add(robots);

// Render: <meta name="description" content="some
description" />
HtmlMeta description = new HtmlMeta();
description.Name = "description";
description.Content = pmdDT[0].description;
this.Page.Header.Controls.Add(description);

// Render: <meta name="date" content="2006-03-25"
scheme="YYYY-MM-DD" />
HtmlMeta date = new HtmlMeta();
date.Name = "date";
date.Content = DateTime.Now.ToString("yyyy-mm-dd");
date.Scheme = "YYYY-MM-DD";
this.Page.Header.Controls.Add(date);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top