MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Meta tags in MOSS 2007 master pages

  Asked By: Ramsey    Date: Jun 16    Category: MOSS    Views: 3207

Does anyone know how I might go about inserting meta tags such as "description" and "keywords" into my master pages and page layouts in a MOSS 2007 external facing site?

Ideally, when an author or editor is editing a page, I want field controls for the meta description and keyword tags, so the author can fill those in and save those with the page content. The problem is that I can't put a server control like a contentplaceholder inside of the content="" attribute on a meta tag. I've tried the following:

<meta name="description" content="<asp:ContentPlcaHolder ID="PlaceHolderMetaDescription" runat="server"></asp:ContentPlaceHolder>" />

The SharePoint designer doesn't like that at all, and the stuff in the content attribute just gets html encoded. following don't work either:

<meta name="description" content='<asp:ContentPlaceHolder ID="PlaceHolderMetaDescription" runat="server"></asp:ContentPlaceHolder>' />

<meta name="description" content="<asp:ContentPlaceHolder ID='PlaceHolderMetaDescription' runat='server'></asp:ContentPlaceHolder>" />

<meta name="description" ID="metaDescription" runat="server" content='<asp:ContentPlaceHolder ID='PlaceHolderMetaDescription' runat='server'></asp:ContentPlaceHolder>' />

Anybody have any ideas how I can get this to work?



1 Answer Found

Answer #1    Answered By: Brittni Harding     Answered On: Jun 16

My approach would be to create a special render control and generate the required HTML code via the control.

1) Create a render control and override the RenderFieldForDisplay method. For an example, see http://msdn2.microsoft.com/en-us/library/aa981226.aspx. This article shows also how to create the custom edit mode but you don't need all of it.
Deploy the custom control as mentioned in the article.

2) Add the contentplaceholder in the master  page (as you already tried), or use the default

<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server"/>

Place this in the <head> section, right after the <title> tag for example.

3) Call the custom control to render the meta  description field in the page layout:

<asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server">

<PublishingWebControls:EditModePanel runat="server" id="displayModeMetadata" PageDisplayMode="Display" SuppressTag="true">
<Mytag:HeadMetadataFieldControl FieldName="MyMetadatafieldname" runat="server"></Mytag:HeadMetadataFieldControl>


Didn't find what you were looking for? Find more on Meta tags in MOSS 2007 master pages Or get search suggestion and latest updates.