Mark on WordPress

WordPress Tip: Reorder your Title Tag

Posted in wordpress by Mark Jaquith on April 23rd, 2008

WordPress, by default, creates <title> tags that look like this: <title>Yoursite » Your Post Title</title>.  Many people want to use <title>Your Post Title » Yoursite</title> instead, to give more importance to the mutable part of the <title>.  There are plugins to do this, but I’d like to show you how a simple change in your theme can accomplish this task. Caveat: this only works in WordPress 2.5 and above.

  1. Open your header.php theme file (if you don’t have one, open index.php or whatever one has your <title> tag)
  2. Look for:
    <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
    (or something similar) 
  3. Replace it with:
    <title><?php wp_title('&raquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>

The first wp_title() argument is the separator character.  I like &raquo; (which looks like: »).  The second argument is whether to echo (print to the browser) the title, or to return it.  We want to print it, so we put true.  The final argument is where the separator should go… on the left or on the right. We want right, so we put "right". Simple enough!

Update: I got confirmation from Matt Cutts at Google that this is better for SEO.

Tagged with: , , , ,

41 Responses to 'WordPress Tip: Reorder your Title Tag'

Subscribe to comments with RSS or TrackBack to 'WordPress Tip: Reorder your Title Tag'.

  1. Otto said, on April 23rd, 2008 at 12:55 pm

    It should be noted that the new ‘right’ optional parameter is new to WordPress 2.5, so you must be using it to do it this way.

    If you have an older version of WordPress, use the Optimal Title plugin instead.

  2. propaganda press said, on April 23rd, 2008 at 1:32 pm

    will give it a shot
    thanks for the tip

  3. Mark Jaquith said, on April 23rd, 2008 at 1:33 pm

    Otto, thanks — updated the post to reflect that.

  4. Jonathan Dingman said, on April 23rd, 2008 at 1:56 pm

    good call Mark.

    I’ve been using the optimal title plugin for a while now to get the same effect as what you’re showing.

    it’s really helped in the search engine results, I feel.

    I actually have a file dedicated to my because of how many different variations I have for it.

  5. Trevor Turk said, on April 23rd, 2008 at 2:24 pm

    Is there a way to do parenthesis like kottke.org?

    http://www.kottke.org/remainder/08/04/15507.html

  6. Daniel Richard | Winning Everyone said, on April 23rd, 2008 at 2:53 pm

    Ahh. Thanks for the WordPress tip there! I’m curious to know if it is okay for SEO if I had used other special characters like ♥ in place of the right angle quote character that you had shown in the tip?

  7. 420bay said, on April 23rd, 2008 at 4:39 pm

    Thanks for the EASY tip.
    usedbongs.com

  8. Mark Jaquith said, on April 23rd, 2008 at 5:18 pm

    Daniel, I can’t say for sure. I would guess that such characters would be ignored.

  9. Bryan Villarin said, on April 23rd, 2008 at 5:57 pm

    I’ve been too lazy to switch this, but you gave me the nudge I needed. Thanks Mark! :)

  10. Kelson said, on April 23rd, 2008 at 6:13 pm

    In addition to SEO, starting with the more specific title is also good for any situation where titles get put in a list — lists of articles, bookmarks, tabs, etc. — because it makes the important part easier to spot while skimming.

  11. [...] Gefunden bei Mark. [...]

  12. Daniel Richard | Winning Everyone said, on April 23rd, 2008 at 10:43 pm

    Lol. I tried using the heart. It looks weird on the title bar so I had it ignored and revert back to the angled quotes. Haha.

    Thanks for the tip guys!

  13. [...] Оригинал. 24 апреля 2008  |  комментарии RSS 2.0  |  trackback   |   Tags: tricks [...]

  14. hso said, on April 24th, 2008 at 12:53 am

    Another SEO fix will be include a tag such that when there is no title, the blog name show up first, like on the home page or paginated pages, archives, search results etc. Code below.


    <title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' »'; } ?> <?php bloginfo('name'); //SEO FIX ?></title>

  15. Mus_ said, on April 24th, 2008 at 1:01 am

    wow! nice.
    it’s good for SEO.

  16. Cigar Inspector said, on April 24th, 2008 at 1:13 am

    Hm, there IS a plugin that does that. It’s called SEO Title Tag.

  17. matthelmke said, on April 24th, 2008 at 4:02 am

    Thanks for the tip! I appreciate it.

  18. Phil Nash said, on April 24th, 2008 at 4:31 am

    I blogged about a method to do this on all pages with a title and display the blog name then the tagline on the home page, here http://www.unintentionallyblank.co.uk/2007/05/01/semantic-header-markup-means-search-engines-will-understand-too/

  19. Carly said, on April 24th, 2008 at 4:33 am

    I use the all-in-one SEO plug in - I must admit that I’ve not looked into it too much to be honest, but I think I’ll optimise my titles at some point today, as they are one of the most important elements of SEO.

    Thanks for the tips :-)

  20. Jack Kennard said, on April 24th, 2008 at 6:10 am

    Carly, your right, titles are currently, and have always been, the most important tag,,, and I also use the same plugin. I have always taken out the name of the site and included the appropriate key words as needed. The title is the first thing viewers see in the search engines so I made that line as appealing as possible.

  21. Daniel Condurachi said, on April 24th, 2008 at 8:02 am

    Thank you very much for this tip. I changed header.php right away

  22. Carly said, on April 24th, 2008 at 8:26 am

    RE: Jack -

    I changed all my titles to post/page name | sitename | myname - as I already try and make the titles of the posts I want people to find Keyword rich, and I want my own name to feature higher in the SERPs.

    I shall have to wait and see if this works in the way I hope!

  23. ShaolinTiger said, on April 24th, 2008 at 10:27 am

    Yah have been using Optimal Title plugin for all my blogs for a long time, glad to see it’s easier to do it natively in WP2.5.

  24. Lodewijk said, on April 24th, 2008 at 10:49 am

    And while you’re at it, you could also simply replace with your own blog name. It will reduce the amount of queries to the database by one for every pageview.

  25. yahoogle said, on April 24th, 2008 at 11:57 am

    Personally I use ‘%post_title% presented by %blog_title%’ or ‘%post_title% on %blog_title%’ via the All In One SEO plugin for WordPress.

    This makes the title element a sentence that is easier to read and probably scores lots of points for accessibility. I read somewhere that page readers (for the blind) read the separators that so many of use have used in our title tags.

    For example this page’s title would be read out, “wordpress tip colon reorder your title tag left-pointing double angle quotation mark mark on wordpress.” How annoying is that?

    @Lodewijk : Top tip - I like that.

  26. Chess Teaching said, on April 24th, 2008 at 12:16 pm

    I have changed the header.php file according to this tip and then realized that nothing has changed because I am already using the All in One SEO plugin.

    ;-(

  27. Alex L. Setiawan said, on April 24th, 2008 at 6:57 pm

    wow…thank’s …
    it’s good for SEO.

  28. [...] webpages. Of course much of this discussion is about Search Engine Optimization (SEO). Having read Mark Jaquith’s WordPress tip on the subject I thought that I would add my own tip via the [...]

  29. 가우리 said, on April 25th, 2008 at 9:50 am

    wow… good tips;

    my tip is …

    -

    what about this tip?

    sorry for my english…

  30. Adam Presley said, on April 25th, 2008 at 2:35 pm

    Nice tip. Thanks!

  31. Best Dog Videos said, on April 26th, 2008 at 9:08 pm

    Thank you for sharing this tip. It fixes just one more of those annoying little things for those of us not as technologically savvy as you. Thanks again!

  32. [...] on WordPress mit dem Hinweis auf andere Anordnung der Template Tags Artikel #644, 27. April 2008 · Tipps, WordPress · 0 Kommentare Tags: SEO, [...]

  33. dani said, on April 29th, 2008 at 9:22 am

    maybe a little bit problem with ” » ” and ” : ” while I need to save the html post :)

  34. Lorelle VanFossen said, on April 29th, 2008 at 8:19 pm

    Did Matt Cutts say anything about the double arrows? Ages ago, there were issues with handling these in search indexes, but that seems to be resolved. Many visually impaired users complain about these and say they do not meet web standards. Personally, I’d love to see them gone and replaced with the traditional dash, so I’m never keen on recommending their use. I like things simple.

    Thanks for the info on the new parameters on the tag!

  35. paulgray said, on May 4th, 2008 at 7:09 am

    Thanks for the tip.

  36. [...] to Mark Jaquith, a WordPress lead developer, the default handling of title tags in WordPress is not optimal. And, [...]

  37. Odessky said, on May 21st, 2008 at 9:55 pm

    Hi!

    Can you give me tip how to create some block on sidebar only root page execept all others?
    Thanks!

  38. toplist said, on May 31st, 2008 at 3:40 pm

    Hm, there IS a plugin that does that. It’s called SEO Title Tag

  39. [...] First — The default WordPress theme shows the name of the blog before the title of the post. Reordering your title tag puts the text more relevant to the searcher’s query (the post title) first, encouraging [...]

  40. Tony Kenobi said, on June 6th, 2008 at 4:53 pm

    I have removed the blog/website name from my title as I think the fact that all pages have it is not ideal.

    What do you think? Is this a good idea?

    cheers
    Tony

  41. mercury thread said, on June 13th, 2008 at 5:35 am

    Cheers mate - I’ve managed to fix my title tags now (had no idea what I was doing TBH) but it’s now worked

Leave a Reply