Make Sure Your Wordpress Blog Serves The Right Page The Right Way

Lucia ( Crochet Jane ;) ) posted a code fix for the trailing slashes problem (If you ain't subscribed to Lucia's blog, there is just something wrong with you).

The Duplicate Page Problem

Basically the problem is this. If your blog will accept http://yourblogdomain.tld/some-post/
and also accept
http://yourblogdomain.tld/some-post
(the first has a trailing slash and the second doesn't), then you are dividing your link juice between "two" identical pages, and Google has to figure out which one they want to use. They might decide on the one you wish they hadn't.

Lets say you are getting oodles of links to the without slashes one, and Google notices that all of your internal links go to the with slashes one. Well, they could decide to prefer the one you are linking to and thus rank your page according to it's link juice and not the one everyone else is linking to.

That's a bad thing. Trust me. Or ask Lucia, she'll tell you the same thing and she has a more trust able face than me.

The Redirection Solution

So, she posted some code you can put into your blog theme's header.php template that will issue a 301 redirect to the trailing slash version of the page if anyone tries to load the no trailing slash version. A 301 redirect is a "Permanently Moved" redirect which tells Google (and anyone else) that they should stop using the page they tried to use and use this other one instead.

So now when Google finds a link to
http://yourblogdomain.tld/some-post (no slash)
they will get the 301 redirection to
http://yourblogdomain.tld/some-post/ (with slash)
and they will automatically start preferring that version. They will also take and Link Love to the no slash page and apply it to the slash page instead, which means that it gets ranked no matter how anyone links to it.

You have options now. You can visit Lucia and get her code (which is my recommendation), or if you are not comfortable with modifying your template files (it is easy though), you can try using the Permalink Redirect Plugin. I've not tried it myself, but I saw a recommendation for it from John Godley, and that's good enough for me.

Another Redirection Fix

Incidentally, there is an identical problem at the other end of your URIs. Namely it's the whole www. or not thing. If some links go to
http://www.yourblogdomain.com/
and others go to
http://yourblogdomain.com/
it can cause the same problem. John Godley has a redirection plugin that lets you manage all kinds of cool redirections from your dashboard. One of the configuration options is to either force or strip the www from requests through a 301 redirection.

Pretty cool, huh? And that's only a tiny bit of what it does.

Trackback URL for this post:

http://danemorgan.com/trackback/40
None
Login or register to tag items
 
Posted In
Tagged With
Like this?
Bookmark & Share:
StumbleUpon Submit to Mixx Save to Google Bookmarks Save to del.icio.us
Click, Copy and Link:
<a href="http://danemorgan.com/blog/wordpress/make-sure-your-wordpress-blog-serves-right-page-right-way">Make Sure Your Wordpress Blog Serves The Right Page The Right Way</a>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I'm actually trying to find

I'm actually trying to find a solution/guide to achieve these page/posts structure for WP blog
Eg ->
Page structure like this :-
domain/page1.html
domain/page2.html
domain/page3.html

But having blog posts structure like this ( I choose the /%postname%/ for post permanent link structure ) :-
domain/myblogpost/
domain/myblogpost2/
...and so on.

Let me know if there is a way to achieve such page/post structure.

Thanks

Data (not verified) | Fri, 06/27/2008 - 14:20

In my blogs I have always

In my blogs I have always used an excerpt or summary on the home page to guard against duplicate content through out my blog.

Link Starz (not verified) | Mon, 06/09/2008 - 23:33

That's what I thought. I've

That's what I thought. I've set up Blogger to redirect to my custom domain url and I notice for some reason it always defers to the trailing slash. It must be the way Blogger or GoDaddy does it. So I've changed all of my home page urls in the template to do the same.

I'm in the process of porting over to Wordpress so I've subscribed to you for future reference :)

Thanks again for the help Dane.

Cheers!

...BB

Blog Bloke (not verified) | Mon, 10/01/2007 - 16:07

Hi BB, Some people (like

Hi BB,

Some people (like me) prefer to have the trailing slash, others prefer not to. It's really a personal preference thing. The important part of this is that it is always the same either way. Either you only allow the page to load with the slash or without.

As for GoDaddy's dashboard I can't answer with complete confidence because I've never used GoDaddy. But if it can detect any attempt to load a page on your site and serve a redirect to the canonical version you establish, then yes, that would be fine.

On Blogger, if all of your page URIs end in a .html then this is not an issue for you at all. But if any of those pages end in a directory type reference, then you'll want to look for solutions to this.

Dane Morgan (not verified) | Sun, 09/30/2007 - 07:23

Sorry Dane, just one more

Sorry Dane, just one more question.

Do you think this method is necessary for Blogger users who don't have the duplication problem and post pages are html docs and not php?

Or is there still a benefit for them doing this as well?

Thanks again,

...BB

Blog Bloke (not verified) | Sun, 09/30/2007 - 02:45

Interesting post Dane. I

Interesting post Dane. I have 2 questions:

Is the trailing slash version more preferable to a url without?

2. Can we not accomplish the same thing with a 301 redirect in our domain forwarding dashboard, like GoDaddy provides?

Thanks for the great post.

...BB

Blog Bloke (not verified) | Sun, 09/30/2007 - 01:31

Yeah, I'm not sure why it

Yeah, I'm not sure why it wouldn't work. I'm using it here and it was plug and play with no problems.

I need to talk to some one in the know and find out what happens if you are using separate checks for multiple elements and redirecting separately for them... Like what happens if somehow the redirect triggers another redirect.

Dane Morgan (not verified) | Sat, 09/15/2007 - 17:42

Hi Dane. I do the no WWW

Hi Dane. I do the no WWW thing in my htaccess file. Works great.

I went to Lucia's site and tried the trailing slash optimization. It does not work on my site, so I posted a question as to why over there. If I paste in her code, then try to view the site without the / I just get a blank page.

Anyway, thanks for the tip and the link!

-Will

Will (not verified) | Fri, 09/14/2007 - 12:56

Hi Dane, Today you have been

Hi Dane, Today you have been given a blog award for the work you do by Scruffyhippo

PGWake (not verified) | Mon, 09/10/2007 - 15:24

[...] topics such as themes,

[...] topics such as themes, plugins, and tutorials to name a few. The most recent post I saw was a nice article presenting 3 ways to make sure WordPress displays the “right page” the &#... Blog Strokes author, Dane Morgan, has a very direct and easy to read writing style, which is [...]

Thanks, Maurice, I

Thanks, Maurice, I appreciate that.

I'll check out Justin's plugin too. I used to use one that Matt Mullenweg wrote, but since I installed redirection to do a couple of other things I figured I might as well use the built in feature and have one less plugin.

Dane Morgan (not verified) | Wed, 09/05/2007 - 07:00

Thanks for the additional

Thanks for the additional pointers Dane, I'm becoming a big fan of your blog :-)

There is also another plugin (not as comprehensive) that will deal with the www or no www which I've been using for some time. Authored by Justin Shattuck you can find it at

http://www.justinshattuck.com/wordpress-www-redirect-plugin/

Maurice (TheCaymanHost) (not verified) | Wed, 09/05/2007 - 01:12

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Restrict text by wrapping in [restrict:roles=<comma separated roles>] and [/restrict]
  • Links to specified hosts will have a rel="nofollow" added to them.

  • Highlight terms in this textarea.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Use <fn>...</fn> to insert automatically numbered footnotes.
  • You may link to webpages through the weblinks registry

More information about formatting options

CAPTCHA
Please fill out this captcha to demonstrate your humanity.
7 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.