471,319 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Dynamic Generation of Meta Tags

Hi:

I'm developing a new C# Web App and I'm hoping to find a way that I can
dynamically generate meta tags for the search engines at the page level.
(I want to do this so that I can have someone update a database with the
appropriate tags - since we cache our pages this won't be a performance
problem).

I am using a master pages so I will need a way to update each page that
we decide should have tags.

I have not been able to locate any info on how to do this. If anyone
can point me in the right direction it will make my day!

Thanks,

Fred
Dec 1 '05 #1
6 4637
Fred,

You should be able to specify a content provider (just like you do in
the master page for the content that is page-specific).

In your individual page, you should be able to reference that content
provider, and set the content of it to be whatever you want.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
Hi:

I'm developing a new C# Web App and I'm hoping to find a way that I can
dynamically generate meta tags for the search engines at the page level.
(I want to do this so that I can have someone update a database with the
appropriate tags - since we cache our pages this won't be a performance
problem).

I am using a master pages so I will need a way to update each page that
we decide should have tags.

I have not been able to locate any info on how to do this. If anyone
can point me in the right direction it will make my day!

Thanks,

Fred

Dec 1 '05 #2
Nicholas:

Thanks for your reply!

I'm a little confused so let me explain. I can build the info for the
meta tags from a database (probably a class library that accesses the db
and prepares the tags).

I don't know how to actually write the meta tags in the header of the
pages.

For example:

<head>
<title>This is my page</title> // comes from title prop of page
<meta name="KEYWORDS" content="this is my content">
</head>

If you have any suggestions I would greatly appreciate them!

Thanks again,

Fred
Nicholas Paldino [.NET/C# MVP] wrote:
Fred,

You should be able to specify a content provider (just like you do in
the master page for the content that is page-specific).

In your individual page, you should be able to reference that content
provider, and set the content of it to be whatever you want.

Hope this helps.


Dec 1 '05 #3
Fred,

That's simple, wouldn't you just do this:

<head>
<title>This is my page</title> // comes from title prop of page
<%
// Get your database stuff here.

// Start cycling through rows.
foreach (DataRow row in rows)
{
// Write the content.
%>
<meta name="<% =row["name"] %>" content="<% = row["content"] %>">
}
%>
</head>
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
Nicholas:

Thanks for your reply!

I'm a little confused so let me explain. I can build the info for the
meta tags from a database (probably a class library that accesses the db
and prepares the tags).

I don't know how to actually write the meta tags in the header of the
pages.

For example:

<head>
<title>This is my page</title> // comes from title prop of page
<meta name="KEYWORDS" content="this is my content">
</head>

If you have any suggestions I would greatly appreciate them!

Thanks again,

Fred
Nicholas Paldino [.NET/C# MVP] wrote:
Fred,

You should be able to specify a content provider (just like you do in
the master page for the content that is page-specific).

In your individual page, you should be able to reference that content
provider, and set the content of it to be whatever you want.

Hope this helps.

Dec 1 '05 #4
Hi Nicholas:

I get the feeling that we are VERY close to solving this.

My question comes down to how would I specify and then write to the area
within the <% and %> - how would I create and reference this.

I'm hoping that this is a "newby" question!

Thanks again!

Fred
Nicholas Paldino [.NET/C# MVP] wrote:
Fred,

That's simple, wouldn't you just do this:

<head>
<title>This is my page</title> // comes from title prop of page
<%
// Get your database stuff here.

// Start cycling through rows.
foreach (DataRow row in rows)
{
// Write the content.
%>
<meta name="<% =row["name"] %>" content="<% = row["content"] %>">
}
%>
</head>


Dec 1 '05 #5
2.0 has new classes...

// Add meta tags
HtmlMeta meta1 = new HtmlMeta();
meta1.Attributes.Add("description", "blah blah blah");
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(meta1);
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"Fred Nelson" <fr**@smartybird.com> wrote in message
news:uM**************@TK2MSFTNGP10.phx.gbl...
Hi Nicholas:

I get the feeling that we are VERY close to solving this.

My question comes down to how would I specify and then write to the area
within the <% and %> - how would I create and reference this.

I'm hoping that this is a "newby" question!

Thanks again!

Fred
Nicholas Paldino [.NET/C# MVP] wrote:
Fred,

That's simple, wouldn't you just do this:

<head>
<title>This is my page</title> // comes from title prop of page
<%
// Get your database stuff here.

// Start cycling through rows.
foreach (DataRow row in rows)
{
// Write the content.
%>
<meta name="<% =row["name"] %>" content="<% = row["content"] %>">
}
%>
</head>

Dec 2 '05 #6
Clinton:

Thanks very much for the help - it looks like this will work for me!

Fred

clintonG wrote:
2.0 has new classes...

// Add meta tags
HtmlMeta meta1 = new HtmlMeta();
meta1.Attributes.Add("description", "blah blah blah");
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(meta1);
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"Fred Nelson" <fr**@smartybird.com> wrote in message
news:uM**************@TK2MSFTNGP10.phx.gbl...
Hi Nicholas:

I get the feeling that we are VERY close to solving this.

My question comes down to how would I specify and then write to the area
within the <% and %> - how would I create and reference this.

I'm hoping that this is a "newby" question!

Thanks again!

Fred
Nicholas Paldino [.NET/C# MVP] wrote:
Fred,

That's simple, wouldn't you just do this:

<head>
<title>This is my page</title> // comes from title prop of page
<%
// Get your database stuff here.

// Start cycling through rows.
foreach (DataRow row in rows)
{
// Write the content.
%>
<meta name="<% =row["name"] %>" content="<% = row["content"] %>">
}
%>
</head>



Dec 2 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

51 posts views Thread by Mudge | last post: by
4 posts views Thread by Tim::.. | last post: by
10 posts views Thread by Ognen Duzlevski | last post: by
2 posts views Thread by Dst | last post: by
16 posts views Thread by Edward | last post: by
2 posts views Thread by thetechturf.com | last post: by
5 posts views Thread by Nick | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.