WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Meta Tags in WordPress

As a search engine prowls your site, it gathers information from the title, headings, content, and Meta Tags such as description or keywords. It compares the words within each of these sections and "ranks" the site dependent upon how well the information matches. We have more information on how to maximize your meta tag references below.

It is important for website developers to understand that a default installation of WordPress does not contain the description and keywords meta tag data. Meta tags can be added manually, through changes to the Theme template files or through WordPress Plugins.

What Are Meta Tags?

The word meta means information about. Meta Tags were created early on to provide concise information about a website. Meta tags list information about the web page, such as the author, keywords, description, type of document, copyright, and other core information.

This is an example of a meta tag for description:

<meta name="description" content="This is the 
description sentence or short paragraph about 
the article or post." />

The most common meta tags examples include:

<meta name="resource-type" content="document" />
<meta http-equiv="content-type" content="text/html; charset=US-ASCII" />
<meta http-equiv="content-language" content="en-us" />
<meta name="author" content="Harriet Smith" />
<meta name="contact" content="harrietsmith@harrietsmith.us" />
<meta name="copyright" content="Copyright (c)1997-2004 
Harriet Smith. All Rights Reserved." />
<meta name="description" content="Story about my dog 
giving birth to puppies." />
<meta name="keywords" content="stories, tales, harriet, smith, 
harriet smith, storytelling, day, life, dog, birth, puppies, happy" />

Why Are Meta Tags Missing?

In the default installation, WordPress does not include meta tags such as description and keywords. Why? Well, let's look at the above tags.

The second tag sets the character set for the page and the third tag sets the language. Specifically, this example sets the character set to be in the English language style as found in the United States, using the ASCII character set. This means that the page will probably feature spellings like "center" instead of "centre" and "humor", not "humour". It also gives information to the browser to recognize the characters as not being Chinese.

The author and contact information lists a specific person. The description tag lists a description of the post that is unique to that post. The keywords also list words found within that post. Are you seeing the pattern?

All of this is unique information. WordPress may do some magical things, but it can't read your mind. If you want to supply search engines better information that is more specific to your web pages, you have to add the meta tag data yourself.

Are Meta Tags Necessary?

A good question to ask is if meta tags are still necessary. They used to be more helpful, providing important information to the Internet browser. As browsers became more sophisticated, they stopped needing a lot of hand holding in order to figure out if your site is in English or Chinese.

Google no longer uses the meta keyword in search result ranking and they confirm this in their Webmaster Central Blog. Some search engines don't use the meta tag information any more because many people abused it. In fact, meta tags may not represent the content of your site, but, it still doesn't hurt your status with search engines if you make use of these little bits of information, and do so truthfully. Furthermore, Google does still use the meta description tag in some situations as part of the snippet of your site displayed in search results.

Without a doubt, content is the biggest contributor to search engine page ranking, so if you want to raise your rankings, make sure you have quality content.

Covering all the reasons meta tags are and aren't important to search engines is beyond the scope of this article. In the Resource section below are some links to more information on meta tags and their impact on search engines.

Putting Meta Tags Back In

To add meta tags to your site, simply add them to the header.php template file in your WordPress Theme, specifically in the head section near the link for the style sheet. At the top you will see the DOCTYPE tag and below that you will see a couple more tags and then the <title> tag, looking something like this:

<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>

Below this line you can add your meta tags. You can add meta tag information such as the content, language, author, contact, and copyright, since these are basically the same on every page of your site.

But what about the 'dynamic' types of information such as description and keywords? This information is unique to every web page on your site. Putting them in the header.php means the information won't change throughout your site.

What you need is something to dynamically add keywords and descriptions on a per-post basis. To add a description, keywords, and other meta tags that are unique to each post or Page generated, you have two choices: you can add them as generic references or you can use plugins.

Generic Meta Tags

If you have a clear purpose for your website, then you can use that information to create generic meta tags and place these in your header. Let's say Harriet Smith is a veterinarian, and enjoys sharing her animal stories on her WordPress blog.

A description meta tag that would describe all of her posts might be:

<meta name="description" content="Special stories and 
tales about dogs, cats, birds, ferrets, and other 
domestic animals as told by Harriet Smith, 
veterinarian. Stories include tales of animal 
bravery and courage, life and death, companionship, 
and the wonderful joy animals and pets bring to 
their human partners." />

If Harriet writes a story about a dog giving birth in the middle of a hurricane, and accompanying the dog were two humans who risked their lives to stay with the dog during the delivery, the descriptive words of bravery and courage, life and death, pets and human, would surely apply. Another story about an animal that returns home to its owner after missing for 5 years might also be described with the words of bravery, courage, life, death, and companionship.

From these two stories, Harriet could create a good generic set of keywords:

<meta name="keywords" content="stories, tales, 
harriet, smith, harriet smith, storytelling, veterinarian, 
vets, animal doctor, bravery, brave, courage, life, lives, 
death, dying, pets, human, companionship, dog, cat, birds, 
ferrets, pets, pet, birth, puppies" />

With these generic description and keywords meta tags, Harriet's website would be accurately described and that should please just about any search engine.

This is the manual style of adding a description, but WordPress can make this easier for you. Add your description, similar to above, in your Admin > Options > General panel. The description is entered in the line designated as Tagline. Then paste in the following in your head area.

<meta name="description" content="<?php bloginfo('description'); ?>" />

WordPress will automatically generate the description. Note: Some Themes use this tag in the header just below the title of the blog or site. If you don't want it there, remove or comment out the tag in the header area.

To get more sophisticated, you can add a conditional tag query that asks "If this is a single post view, show the post title; if this is a multi-post view, show the blog name and description." The conditional tag query looks like this:

<meta name="description" content="<?php if ( is_single() ) {
        single_post_title('', true); 
    } else {
        bloginfo('name'); echo " - "; bloginfo('description');
    }
    ?>" />

Using Meta Tag Plugins

There are several Plugins that allow the blog administrator to set the keywords, description, and other meta tags to be unique on each post. These plugins make use of the Custom Fields in the Write Post Panel. You can find meta tag Plugins in the Official WordPress Plugin Directory.

Using Meta Tag Plugins allows you to customize each of your meta tags, and to choose the ones you want to add, or not, on a per-post basis. This allows your meta information to better describe each page.

Meta Tag Resources

Here are some sites that will help you learn more about meta tags, how they work, and why you should or shouldn't use them.