SharePoint SEO: generate meta descriptions for your public-facing SharePoint pages

No, Meta Description tags are not dead. Keywords, sure. But not descriptions. They’re great for making sure your pages are accurately represented in search results, and they tell the search engines a bit more about your page. This is important to me because as I finish touching up a new public-facing website in SharePoint 2010, I’m on a mission to make sure our SEO and rankings don’t take a dip as a result of the switch. Getting your hands into SharePoint to tweak things like meta tags, etc. can be tricky. But here is a (seemingly) simple solution.

For info on what Google says about best practices for meta description tags, click here

So here goes:

  1. Create a new site column (my preferred method) called Meta Description
  2. Add this new site column to your custom content type (still keeping things clean)
  3. Add the following code to the HEAD section of your Master Page:
     <asp:ContentPlaceHolder id="myMetaDescription" runat="server" />
  4. Add the following code to your custom page layout (I put mine at the bottom). Note that the SharePointWebControls (commented out here) piece is the custom column that we created earlier. So your FieldName will naturally be different than mine. Uncomment and replace with your field.
    <asp:Content ContentPlaceholderID="myMetaDescription" runat="server">
     <asp:literal ID="meta1" runat="server" Text="&lt;meta name=&quot;description&quot; content=&quot;"/>
     <!-- <SharePointWebControls:NoteField FieldName="0383b91e-83c4-4bc3-9ce3-d40e7a8acebb" runat="server"></SharePointWebControls:NoteField> -->
     <asp:literal id="meta2" runat="server" Text="&quot;&gt;" />
    </asp:Content>
    
  5. Now, when you click Edit Properties on your page, you’ll see a field called Meta Description, which is where you’ll type a short snippet that search engines will love!

To double check everything, create a new page, edit its Meta Description field, and then view source in your browser to make sure your description is coming through. Caveat: if you don’t put anything in the meta description field, this won’t play well. Looking for a fix to only show the meta tag if there is a description. Will update if I find it.

And of course, if you have a better way of doing this, or any suggestions, let me know!

Credit: most of this solution was created from code on this forum.

#update [05/25]: I just stumbled across this solution here as well. I’m not sure which came first…but thanks to whoever it was!

About bentedder

Ben Tedder is a front-end web developer. He loves WordPress, SharePoint, and Drupal, along with jQuery, CSS, and good 'ol HTML. +Ben Tedder on Google or follow @bentedder

Comments

I try to respond personally, but things get busy sometimes :)
  1. Liz says:

    Hi Ben,
    Thank you for the post! I am working on a public-facing SP website and this is extremely helpful. I also wanted to ask you about page titles. Right now, on the site I am working with, the page title is associated with the page heading. I would like them to be different from each other, and that the page title field be indexed by Google.
    Any thoughts?

  2. Phil says:

    Ben

    Thanks for the great post!

    One thing: when I changed my page layouts as directed above, my affected pages lock up. Can’t scroll on the page and when I click to Edit the page (from the ribbon), I just get an indefinite “Loading…” message.

    Any thoughts?

    Thanks!
    Phil

Trackbacks

  1. [...] my page layouts to accept a new SEO meta description site column (as per this post, for example: http://www.bentedder.com/sharepoint-seo-generate-meta-descriptions-for-your-public-facing-sharepoint…), my pages based on the page layout lock [...]

Join the discussion!