Dynamic Generation of Meta Tags

  • Thread starter Thread starter Fred Nelson
  • Start date Start date
F

Fred Nelson

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
 
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:

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
 
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>
 
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
 
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 said:
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

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>
 
Clinton:

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

Fred
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 said:
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

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>
 

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

Back
Top