Web Development

Google-Optimizing entries for better keyword indexing from underscore to hyphen

GoogleGuy Says in Google Hyphen are better than Underscores, because they separate the keywords, while underscores connect them together…. that means my weblog was un-optimal because all entry titles were “one keyword” instead of meaningful connection of words…

So I guess nobody on earth will search for

</p>

	<p>google_toolbar_with_popup_blocker_and_blogger_support</p>

	<p>

while I can imagine some that might try a search like

</p>

	<p>google toolbar popup blocker</p>

	<p>

So reading this entry I noticed, that the individual archives not optimal for Google relevance.

So far I created files like the above concatinated

</p>

	<p>google_toolbar_with_popup_blocker_and_blogger_support.php</p>

	<p>

in the date-subdirectories.

So how did it change to

</p>

	<p>google-toolbar-with-popup-blocker-and-blogger-support.php</p>

	<p>

when the “Dirify” command of Movable Type converts everything to neat, yes better readable, underscores?

If you are not interested in more hits and better ranking from Google, ignore this post, else read on for

a 1-Byte fix patch for much better search-results (hopefully :-)...

Instructions:

1) we have to patch a file “util.pm” of the MT release (I am based on 2.64, but you can try to do it for other versions)

2) then we have to change the Archive File Template for Individual Entries(these allow you to customize the names/paths of your archive files, using standard Movable Type tags. This allows you to impose a directory structure and hierarchy on your archives)

3) then we have to make sure that we can redirect some engines to the correct new files instead of the old ones (let’s assume that we want to add some stuff or change the layout or just remove the old files)

Step-by-step

Phase 1

a) locate util.pm in /cgi-bin/lib/MT

b) change line 331 from


      =~ tr! !_!s;

   

to


     =~ tr! !-!s;

    

c) upload it to your server

Phase 2

be aware, that all your old pages will remain there for the re-generation, which can be useful if external links to your weblog reference them – I just let them stay there because even 1000 entries are just a bunch of HTMLs and I guess not more than 10-20 megabytes (well – depends a lot on your space and texts written) – but be aware… that’S important – if you delete them and take 404 into account then ok – i won’t

a) go to weblog-config -> archiving -> archive file template for individual

and enter something like I did

</p>

  [ format=”%Y/%m/%d”$]-[ dirify=“1”$].php

	<p>

which will put all indiv entries into a subdir for year and one for month, with the day of month prefixed (I hate subdir-overload) and finally the complete entry-title with HYPHENS as separation (if you uploaded the util.pm correct)

b) rebuild all

c) hope for even more google-hits

I hope this was clear, I am a little tired because of the heat – so for questions please ask them in the comments…

Phase3

a) now we want to redirect all folks getting urls with underscores to those with the hyphens…

so open the .htaccess in your weblog directory, if nothing exists, create one

and start with

</p>

	<p>RewriteEngine on</p>

	<p>Options +FollowSymlinks</p>

	<p>RewriteBase   / </p>

	<p>

which is important to make Apache enable URL rewriting.

Then we add a line for easy cases like category-page redirct like

</p>

	<p>scripting-webdev instead of scripting_webdev</p>

	<p>

</p>

	<p>RewriteRule /a/(.<strong>)_(.</strong>)$  				/a/$1-$2 		[NC,L]	#ok  a/c/123_xyx.abc => a/c/123-xyx.abc</p>

	<p>

Unfortunately I got absolutely NO CLUE how to create a Search/Replace expression in Mod_Rewrite, so we will add some more lines to handle those files with more underscores:

</p>

	<p>RewriteRule /a/(.<strong>)_(.</strong>)_(.*)$  				/a/$1-$2-$3 		[NC,L]	</p>

	<p>RewriteRule /a/(.<strong>)_(.</strong>)_(.<strong>)_(.</strong>)$  				/a/$1-$2-$3-$4 		[NC,L]	</p>

	<p>RewriteRule /a/(.<strong>)_(.</strong>)_(.<strong>)_(.</strong>)_(.*)$  			/a/$1-$2-$3-$4-$5 	[NC,L]	</p>

	<p>RewriteRule /a/(.<strong>)_(.</strong>)_(.<strong>)_(.</strong>)_(.<strong>)_(.</strong>)$  			/a/$1-$2-$3-$4-$5-$6 	[NC,L]	</p>

	<p>RewriteRule /a/(.<strong>)_(.</strong>)_(.<strong>)_(.</strong>)_(.<strong>)_(.</strong>)_(.*)$  		/a/$1-$2-$3-$4-$5-$6-$7	[NC,L]	</p>

	<p>RewriteRule /a/(.<strong>)_(.</strong>)_(.<strong>)_(.</strong>)_(.<strong>)_(.</strong>)_(.<strong>)(.</strong>)$	/a/$1-$2-$3-$4-$5-$6-$7	[NC,L]	</p>

	<p>

Now we have rules to replace up to seven underscores in the URL with hyphens when asking for a file.

the [NC] means to ignore case

the [L] means to stop processing after applying this rule (i have some more)

why did we not add a® to Rewrite the URL?

I read some issues about Googe and other search engines not liking pages with redirect http codes – ok – so we let them believe that the _ URL still exists… :-)

b) now we can safely delete all files with up to 7 underscores :-)

Average rating
(0 votes)

Comments

Google-Optimizing entries for better keyword indexing from under

There is an easier way to get hyphens instead of underscores for MT individual archives. While "dirify" only does underscores, a plugin called "dirifyplus" does hyphens (and other flexible options). You can find dirifyplus at http://ed.fanworks.net/mt_stuff/dirifyplus.phtml. I use it on GoogleGuy Says, and it works great.

Google-Optimizing entries for better keyword indexing from under

excellent.. it was so simple i cant understand why i didnt make it earlier :)

many thanks :)

Google-Optimizing entries for better keyword indexing from under

I've been trying to implement a similar method on my own site to improve search engine rankings. I've got the dirification with the '-' instead of '_', but I'm having problems with the redirection.

Where you use /a/, I have something like /archives/2004/09/20/. Is there any way to specifically search for the last hierarchy level in the string and apply the rules to that level?

Thanks,
Jason

Similar entries