Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Hyphens in directory names

Quote Reply
Hyphens in directory names
Is there a simple way to replace the underscore that is used in naming multiple word directories with a hyphen?

For example:

links/my-keyword-phrase/index.html

instead of

links/my_keyword_phrase/index.html
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
Only by editing the code. Edit admin/Links/Category.pm in sub _clean and change:

$name =~ s/[^\w\d_\-\/]/_/g;

to:

$name =~ s/[^\w\d_\/]/-/g;

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Hyphens in directory names In reply to
Thanks Alex. I tried this but unfortunately it didn't work (made no difference at all so I'm not sure what is going on).

Would this create new category names after a build or should I delete them all manually and let Links rebuild everything?
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
I don't understand the code above, but if it's only substituting the underscore for a hyphen should it be this instead:

$name =~ s/[^\w\d_\-\/]/-/g;

In Alex's example a \- seems to have disappeared?
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
Well if you are trying to replace all instances of - with - .. wouldn't that be a bit silly?

$name =~ s/[^\w\d_\-\/]/-/g;

....i.e if you are telling it to replace -, then its just doing more work than it needs to do Wink

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
Hi,

Sorry, it's actually a bit harder then I thought. I don't think this will be a simple change to do.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Hyphens in directory names In reply to
No worries Alex, thanks for trying anyway!

This option would be a nice addition to Links SQL. At the moment Google does not recognise the underscore as a word separator but it does with a hyphen.

Keywords in the URL can slightly improve search engine results.
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
My issue too. Anyone else find the answer to this problem?

Thanks
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
In Reply To:
No worries Alex, thanks for trying anyway!

This option would be a nice addition to Links SQL. At the moment Google does not recognise the underscore as a word separator but it does with a hyphen.

Keywords in the URL can slightly improve search engine results.

For my own, I would suggest it is a notion that Google doesn't recognize the _ character. I've just tried some searches myself and the results (one 2,000,000+ results) have pages/sites in the top 10 that use underscores in the name. Try "michigan lodging" (without quotes) for example. 1,600,000+ results and two of the top 10 use underscores.
Quote Reply
Re: [Karen] Hyphens in directory names In reply to
In Reply To:

For my own, I would suggest it is a notion that Google doesn't recognize the _ character. I've just tried some searches myself and the results (one 2,000,000+ results) have pages/sites in the top 10 that use underscores in the name. Try "michigan lodging" (without quotes) for example. 1,600,000+ results and two of the top 10 use underscores.[/reply]

This has been discussed at great length in multiple threads at webmaster world. Having underscores is not a "penalty" it is simply poor SEO over hyphens. If a page is optimized correctly it WILL show in the results. The thing is that underscores hurt, but don't kill your rankings. If the page is SEO tuned very well, the underscore won't do too much damage, but it does not help either. Google most certainly DOES recognize the underscore, it treats it like a caracter, whereas the hyphen is treated as a blank space. There is an employee of google in WW that confirmed this in the many discussions over there on this topic.

Here's the deal, Keyword1_keyword2 is recognized as ONE long word whereas Keyword1-keyword2 is 2 normal words.

Mike
Quote Reply
Re: [Palehorse777] Hyphens in directory names In reply to
Mike is correct. Hyphens are a very small piece of the puzzle but they have been shown to be more desirable than underscores in URL names.
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
I know I personnaly do not like underscores. I try to envision the consumate user typing along at 1 word per minute using the hunt and peck method, having the stop and look for the shift bar to put the underscore in the URL...

</not a clue>
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
In Reply To:
This option would be a nice addition to Links SQL. At the moment Google does not recognise the underscore as a word separator but it does with a hyphen.
I found a work-around for this problem, sort of a band-aid. check out this thread.
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
Just checking again to see if anyone can shed any light on this. Mike's shortcut above is not really suitable for me as it changes the category name format in the breadcrumb, titles etc. and I don't want to go back and change all that.

There must be a simple bit of code somewhere that changes all foreign characters in directory names to underscore. All I want to do is change the underscore to a hyphen - it should be simple? I noticed in Links 3 there is no category.pm in admin/Links/Build - is build.pm where this happens now?

I've got no problems changing the core files, except that I don't know where this change needs to be made.

Last edited by:

aus_dave: Oct 26, 2005, 7:14 PM
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
Take a look at the StaticUrlTr plugin, that essentially does what you want, but you might want to change it to suit your needs a little better.

Adrian
Quote Reply
Re: [brewt] Hyphens in directory names In reply to
Thanks Adrian. I am using dynamic pages with mod_rewrite so this doesn't really work for me (it changes the URLs fine but I get a 'Don't exist' error).

Last edited by:

aus_dave: Oct 27, 2005, 4:22 PM
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
It's a pitty Dave isn't it that GT couldn't just go that little bit further and have the plug-in cover the two options available in Links Static and Dynamic Unsure

The previously avaialble plug-in from webmaster33 didn't get enough attention for it to grant an upgrade...

I'm having to do it all by hand... Frown

Good job I'm not planning on many categories

John
Significant Media
Quote Reply
Re: [Jag] Hyphens in directory names In reply to
Yes, the category names would look nicer with hyphens but I won't lose too much sleep over it Wink.

There must be a small piece of code somewhere that converts all the foreign characters to underscores. If I could find it I would think it to be pretty simple to change that to hyphens, maybe I'm on the wrong track though too!
Quote Reply
Re: [aus_dave] Hyphens in directory names In reply to
Hi Dave,

I was referring to this plug-in that has quite a few more functions and works in both static and dynamic, sorry "worked" since Links 3.X has been modified in a way that means it needs to be rewritten...

http://www.gossamer-threads.com/...i?post=284364#284364

John
Significant Media
Quote Reply
Re: [Jag] Hyphens in directory names In reply to
I did come across that thread in my searches but I thought it was a bit too powerful for what I wanted to do - changing underscores to hyphens seemed like a very simple matter.

I would probably consider buying that plugin if Konrad updated it, but only while my new site is in the developmental stage. Once it is fully spidered and indexed by Google and the site grows, it's not worth the trouble of changing all the URLs.