Using web.sitemap to hold SEO meta data

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

here's what i've got so far in my code beind

if (SiteMap.CurrentNode != null) {
if (SiteMap.CurrentNode["metaKeywords"] != null)
{
strMetaKeywords = SiteMap.CurrentNode["metaKeywords"];
strMetaDescription = SiteMap.CurrentNode.Description;
}
else
{
strMetaKeywords = "this is a test";
}
}

if (!Page.IsPostBack)
Page.DataBind();
}


So, it pulls Description and metaKeyword from the siteMapNode and
populates the webform meta tags. It work well. What i'm not sure how
to do is populate steMetakeywords or strMetaDescription with content
if there is no siteMapNode for a given web form (that's what i'm
attempting to do in the ELSE statement).

any ideas?
 
here's what i've got so far in my code beind

if (SiteMap.CurrentNode != null) {
if (SiteMap.CurrentNode["metaKeywords"] != null)
{
strMetaKeywords = SiteMap.CurrentNode["metaKeywords"];
strMetaDescription = SiteMap.CurrentNode.Description;
}
else
{
strMetaKeywords = "this is a test";
}
}

if (!Page.IsPostBack)
Page.DataBind();
}

So, it pulls Description and metaKeyword from the siteMapNode and
populates the webform meta tags. It work well. What i'm not sure how
to do is populate steMetakeywords or strMetaDescription with content
if there is no siteMapNode for a given web form (that's what i'm
attempting to do in the ELSE statement).

any ideas?

Ok, i've made some adjustment. Here's my updated code:
if (SiteMap.CurrentNode != null)
{
if ((SiteMap.CurrentNode["metaKeywords"] != null))
{
strMetaKeywords = SiteMap.CurrentNode["metaKeywords"];
}
else
{
strMetaKeywords = "this is a test 1";
}
if (SiteMap.CurrentNode["Description"] != null)
{
strMetaDescription = SiteMap.CurrentNode.Description;
}
else
{
strMetaDescription = "this is the description from
code behind";
}
}


if (!Page.IsPostBack)
Page.DataBind();


It works fine, expect for a small bug. If siteMapNode is as follows:

<siteMapNode url="~/index.aspx" title="Home" description=""
metaKeywords="" id="homeNavItem">


the canned metaKeyword message doesn't display.

any thoughts?
 
Back
Top