Oct
28
2008

How to Modify Your WordPress <title> Tag for Search Engine Optimization

by   |  Posted in Tutorials  |  71 comments

Search engine optimization is one of the more important things, if not the most important, when it comes to your website. Sure, the way it looks and work are both important, as well as the content, but if Google or Yahoo can’t index your pages properly due to the fact that your site isn’t optimized then all that work is for nothing.

There are a few plugins available for WordPress that help with search engine optimization but I’ve found that they don’t allow you to really control all the elements you would want to plus I prefer to hard code certain things, just in case the plugins don’t work with updated versions of WordPress.

The following is a very simple change to perform, but in my opinion, is extremely important for every WordPress install.

Setting up your <title> tag to work dynamically

Whenever you create a web page, you must give that page a name. That is what appears at the top of your browser window.

In the header.php file of your WordPress theme you will come across a bit of code that looks something like this.

<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>

What this piece of code does is grab the name of your blog and use it for the title of your web page. You control this info by going to your wp-admin panel => Settings => General.

If you are on the main page of your website, you will see the name of the blog at the top of the browser but if you are on on a post’s page then you will see your blog name, “Blog Archive” and then the title of the post.

The basic problem with this default code is that the name of your blog always comes first. Is the name of your blog the most important information or is it the name of your post? Hopefully you said the name of your post.

So, the solution is pretty simple. Let move some things around until we get something like this.

<title><?php if(is_home()) { echo bloginfo(‘name’); echo|; echo bloginfo(‘description’); } else { echo wp_title(|, false, right); echo bloginfo(‘name’); } ?></title>

The first thing we’re doing here is checking to see if it is the home page. If it is then we’re going to show the blog name and then the tag line (see image above on where to go to change this), separated by a ” | ” character. You can change this to whatever you want but remember to leave the blank spaces before and after the character you choose. Next, if it is not the home page, we are going to show the name of the post (wp_title), but only if there is one. That is what the false parameter is gonna check for us. If there isn’t one then it will just show the blog name. But if there is one then it will show the post name then the blog name, separated once again by a ” | ” character.

Check back for more search engine optimization tutorials and tips.

You can get more information on the WordPress tags used here by going to the WordPress Codex page.

About the author:

A freelance web developer living in Montreal who spends most of his time writing for this site and building Premium themes for WordPress. You can find him on Twitter @bavotasan.

Site5 Affiliate Link
Share the love...

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Short URL: http://bit.ly/djPIXc

Discussion 71 Comments

  1. suchmaschinenoptimierung on October 7, 2009 at 12:37 pm

    Hello folks, yes, this is quite good for seo persons and I agree with the above points. Thank you for this information.

  2. Detoxseo on October 27, 2009 at 6:51 am

    im just a beginner in Search Engine Optimization and i am still doing quite a lot of research about basic SEO.

  3. heaven_poet on November 3, 2009 at 6:35 pm

    very nice post
    I have a question for you
    can it works in all kind of theme?

  4. Marvin on November 16, 2009 at 12:41 pm

    im a newbie in Search Engine Optimization and i still need to study more on internal linking. Currently, what i do to optimize my website is just make as many backlinks as possible.

    • HealthcareOutSourcingServices on December 22, 2009 at 9:10 am

      See what the major web 2.0 sites (Twitter,Facebook etc) are linking up with and try to get a link with those sites.

  5. Badal on November 16, 2009 at 5:56 pm

    I like all points you share here. Do open source projects using the same tactic? Their products are completely free but they can still make most out of them and even become rich. For instance, Firefox earn millions last year although it doesn?t require users to buy.

    • HealthcareOutSourcingServices on December 22, 2009 at 9:07 am

      Open Source Projects earn revenue differently. End users or customers do not pay most of the time. Its advertising mostly or the service charges they bank upon. Consider major search engines (Google/Yahoo/MSN), their products are open source in the sense that it is freely for people to use but their earnings come through advertising.

      Earnings for open source programming languages like Python or ERP packages like ERP5 come through services/technical issues they resolve for those who have installed/downloaded/used their product.

  6. Backlinks on December 30, 2009 at 7:32 pm

    This was very useful for me as I am just starting to learn php basics and it was very hard for me to find how to do this myself.

  7. Lee on January 23, 2010 at 3:56 am

    I am using Jeff Johnson’s new SEO plugin. Thats really great, its an all in one plugin with lot of features. . .

  8. foot on February 5, 2010 at 11:24 am

    Thank your for this useful post for a newbie

  9. backlinks on February 13, 2010 at 3:06 am

    Very useful information. But I think there are plugins available, which can do the trick.

  10. Seo Firma on February 20, 2010 at 4:48 pm

    For wordpress there is a plugin called “All in One SEO Pack” which is a great tool to customize your page/post titles, meta description and for keywords.

  11. Yudu on March 10, 2010 at 11:04 pm

    Awesome stuff. I used to have to try and do this all the time but wordpress developers are smart. I’m happy with the All In One SEO pack. I actually don’t even bother with it on most stuff because I title posts well. However, when I want to switch it up there is never a problem using the pluggin.

  12. Vistabay rehab on March 12, 2010 at 9:59 am

    Title plays a vital role in site optimization & it is absolutely necessary to have titles for every contents of your site so that it can be indexed quickly by search engine quickly.

  13. CricketVillage on March 13, 2010 at 4:56 pm

    Thanks for the great info, i was looking for something similar as we all know how important is to put right title according to the post. As google give more importance to the title.

    • SEO Software on April 9, 2010 at 6:55 pm

      Sorry CirckrtVillage but i have to disagree with you on the “google give more importance to the title”
      unfortunately most people still belive the myths of the ’05-’07 era where google place more weight on the “Keyword Density”,”Titls”…etc but this has been proven to be not true to some extend…ofcourse they still have some weight on google but not as much as it was few years ago.

    • c.bavota on April 10, 2010 at 9:00 am

      The thing about titles is that every search engine uses them to index your page. So if your title is “Using WordPress” or “Using WordPress to Develop Your First Blog”, someone who is skimming a search results page might find the later more useful and click on it first, giving that page more hits and possibly, in the end, more backlinks.

      Being more precise with your page title and having a function in place to dynamically change it on every page is a step in the right direction when it comes to SEO.

  14. best seo on March 16, 2010 at 2:03 pm

    if there isn’t availabe a plugin for the cms (as WP for instance), we should have the query before loading the page. we can take first 6 – 10 words from the title and display it within the title tag. the same story with description, which can be taken from the main area of the content. this is a simple working and fully functional dynamic title and description. the title can be appended to url, after having inserted “-” char between words and stripped them of illegal chars.

  15. divx guy on April 20, 2010 at 1:03 am

    The quotation marks are messed up with the example code…its easier just to use all vertical ones.

    Aside from that its working great thanks :)

    • c.bavota on April 20, 2010 at 12:59 pm

      Fixed. Thanks.

  16. Neil Web on April 26, 2010 at 3:32 pm

    Great post, very useful information,particularly for a wordpress novice. Just installed the plugin and its so easy to use. Thanks!

  17. Jenniffer Posch on April 28, 2010 at 11:07 am

    i am a newbie in Search Engine Optimization but i think that the submission of articles in article directories is one of the best ways to gain backlinks. :

  18. Lucina on April 30, 2010 at 12:16 pm

    Thank You – this is exactly what I needed!

  19. Chris on May 14, 2010 at 7:42 am

    Great info! Exactly what i was looking for! I was getting quite annoyed with seeing my pages turn up in google with ‘blog archive’ in the title. :)

  20. Web Design Melbourne on June 14, 2010 at 8:32 am

    Am I missing something here – I though all-in-one SEO allowed you to do this without all that tedious mucking about in hyperspace.. er sorry, in php

    • c.bavota on June 14, 2010 at 11:43 am

      There are plugins that do this but if you are building a premium theme or something like that, it makes sense to include the above code since you never know what plugins someone might use.

    • Web Design on April 27, 2011 at 8:03 pm

      Thanks for this mate! Also guys, also don’t forget to do the same with the permalinks in the URL > if not homepage, I would suggest this:

      /%postname%/%category%/

      Always remember, relevance starts left and loses value to the right ;-)

  21. Hannah Hall on June 24, 2010 at 12:13 am

    Any good but inexpensive seo software out there ?.~”

  22. Dennis Board on August 1, 2010 at 2:43 am

    Great Post! This helped me get my titles straight at http://dennisboard.com. I was struggling with just having a simple title before I found this.

  23. gizmo gadget and software on August 7, 2010 at 5:32 pm

    Thanks a lot, i’m not looking for the title tag but it makes me understand on how to call the title text on each pages to optimize on page seo

  24. Phil on August 28, 2010 at 3:28 pm

    Very useful post, thanks.

  25. Zack on August 30, 2010 at 3:48 pm

    Is there a way to add extra words to your homepage title that are not found in ‘blog title’ or ‘blog tagline’ fields?

    • c.bavota on August 31, 2010 at 9:42 am

      Sure. Just add the plain text between your title tags.