Optimize your Meta Description Tag


background image

The Meta Description Tag (placed between the head and /head tags) is used by some search engines to create the snippets of text that you see right below the results on search queries. It does not carry any weight in the search algorithm of Google, but it does carry a certain weight for Yahoo and other smaller search engines so you should not neglect it altogether.

One problem with the Meta Description Tag of most websites is that it is static. People usually include a general description about the site, which is suitable only to the home page. Should a visitor find an internal page (say a single post) through a search engine the tag will be the same, containing no information about the content of that internal page whatsoever. You can use the SEO tools listed here to check the quality of your meta description tags.

In order to optimize your Meta Description Tag you should make it dynamic, making sure that it will include the first few lines of text of every single page on your site. A very simple way to do this under the WordPress platform is to make the Description tag equal to the post excerpt, like the code below illustrates.

<meta name="description" content="<?php the_excerpt() ?>" />

Alternatively you can download a plugin called Head META Description. Just upload the plugin, activate it and insert the following line on your header:

<?php head_meta_desc(); ?>

The plugin will generate the Meta Description automatically, either by extracting the first words of your posts or by displaying the post excerpt (you can configure it).

Browse all articles on the SEO category

36 Responses to “Optimize your Meta Description Tag”

  • Zelimir

    But what if my front page is static, and it doesn`t have any excerpts or posts. Just static content. How will I display the meta description tags for my homepage then?

    I tried using that plugin you recommended, but I only got a
    “Fatal error: Call to undefined function head_meta_desc() in /home4/cestitke/public_html/howtocureyeastinfection/wp-content/themes/savana1/header.php on line 10”

  • Vhalala

    Nice article about meta desc … thanks

  • Daily Good Tips

    Yes, dynamic is better than static.

  • Bang Kritikus

    How to set meta tag in blogspot template ???

  • Syahuri

    Hi Daniel, I have installed All in One Seo Pack plugin.
    Must I replace All in One Seo Pack with this plugin?

  • Nicholas Turner

    Wow, the plugin was very useful. I was tired of all my pages coming up with the default tagline and this seems to have fixed it (at least when viewing the source). I’ll have to wait and see what Google does with it to see if it really works. Thanks for the very useful information (and plugin link!).
    — Ourlullaby.com

  • Adrian Muñoz

    How to do the same on blogger?

  • SEO Genius

    Great article, i believe google does not index your pages if they have the same description tags as they see them as the same page.

  • CandyShopGirl


    What do you think about Apple Iogo? >:)

  • Daniel

    Jamie, open your WordPress control panel, then go to “Presentation,” then “Theme Editor”.

    On the right side of the screen you’ll have a list of the files of your theme.

    Open the “Header” or “header.php” file, that is where the code goes.

  • Jamie Boyle

    Can someone tell me where you put that code, you say after the header???? I not to familiar with that code stuff, could someone write a sample code so i can look in my template, Want to make sure I do this right. Also I use blogger is that compatible with it the download you talked about wordpress.

    Please help, i have one meta tag in my blog at start but when i did another post, i am no longer ranked high.

  • Ajay

    Hi Garry, my vps went down earlier today.

    Check now, it should be up and running.

  • Garry

    It might be worth checking out this plugin which does pretty much what we are trying to do here. You can overide the tags too in the control panel which makes it quite handy.

  • Garry

    hmmm having some difficulty accessing your site ajay.

    I’ve been looking at some plugins to do the meta bits, so I’ll see how I get on with them.

  • Ajay D’Souza

    Garry, seems to be working on my blog.

    Check out the archives.

  • Daniel

    If am not wrong you can force the search results or category-archive pages to get the first few lines of posts even if they have no excerpt written.

    I am not sure how you would do that for the metaexcerpt function though.

  • Garry

    I don’t know whether it’s just me being a div, but does the excerpt function work differently in 2.1? Before I was sure I was getting the first few lines of each post, but now I have to actually enter an excerpt for it to display…. anyone else noticing this on their 2.1 blog?

  • Garry

    Code sent via contact form.
    Glad I can be of help 🙂 Still very new to blogging to sites like this are a massive help.

  • Daniel

    Gary, send to me the code and I will try to update my post since your method is more effective.

    Thanks for the help man.

  • Ajay D’Souza

    Do blog about it?

  • Garry

    aha, didn’t think of that. Thanks

  • Ajay D’Souza

    Hi Gary,

    Any function you can create can be put in functions.php of the theme file. This ensures it remains even on upgrade.

    Can the share the function you created.. the code I mean.

  • Garry

    I created a new function in /includes/template-functions-post.php
    I copied the_excerpt function and renamed it the_metaexcerpt()
    The I found a good striphtml function and added that in, then in the_metaexcerpt function I just put the striphtml function around the content that was being echo’d in the php.

    I tried posting the code here, but it didn’t seem to like it.

    Just remember though that if you update wordpress you’ll lose this function as it’s part of the core files.

  • Ajay


    I don’t think it will mess up your layout, but then again you can’t be sure. Worse thing though is your site doesn’t validate and could mess up bots… again can’t be confirmed.

    I tried using strip_tags around the excerpt but it didn’t work.
    I guess the only option you have is to create a manual excerpt for each and every post.

    It could be additional work here for you but can just about work since your’s is not a personal blog.

    As for me… well I’m stuck with not using it!

  • Daniel

    Hey Ajay, you are right I had noticed that as well. I guess it has to do the wordpress code, and it would be a mess to create a second excerpt just for the header.

    Do you think the tags on the header can mess something up?

  • Ajay

    Hi, I’ve found that using the_excerpt tends to break validation on the blog, because WP adds the paragraph tags as well automatically. Not sure why.

  • Bes

    Nice tip Daniel! I always wanted to use the excerpt field in the WordPress writing editor for something other than photoblog archives. This means some extra work and a little bit more space on the WP database, but it also means a summary for each post on a site that can be displayed in other places too.

  • menghua

    great tips… I’ll insert this into my meta tags later..

Comments are closed.