dashes vs. underscores in filenames

In the old days of the web, file names usually didn't go out of their way to convey information about their contents. If the page was about dogs, sure, it might have been "dogs.html", but if it was "Care and feeding of poodles", it was more likely to be "poodles.html" than anything else.

That's all changed. The conventional wisdom nowadays is that search engines pay attention to file names as part of their analysis, so that poodle page is probably "care-and-feeding-of-poodles.html" now.

That brings up a question, though: should it be "care-and-feeding-of-poodles.html" (dashes) or "care_and_feeding_of_poodles.html" (underscores)? A Google search for "dashes vs. underscores" will tell you that dashes are the smart choice, but I didn't find any place that tells you why.

One hint might be found in Perl regular expressions. If you use "/w" in a Perl expression, that matches alphanumeric characters plus "_". The "/w" is often used to break up sentences into words. So "hello-there" is two words if "/w" is used, but "hello_there" is only one. I'm not saying Google or any other search engine uses Perl to parse your pages (though they might), but Perl got the idea of "_" being part of a word from long established practice. So, if you want search engines to "see" separate words, you should probably use dashes.


There is another point to consider, though: "care-and-feeding-of-poodles.html" is a lot of typing, and although most passing of links is down by cut and paste rather than word of mouth, length and difficulty may be something to think about. I think I'd probably make that "poodle-care.html". There is also speculation that search engines may penalize you for too many dashes in a link because it starts looking like spam: "lets-cram-every-keyword-we-can-into-this-link.html".

So, use dashes and keep it shorter rather than longer.



Got something to add? Send me email.





(OLDER) <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> dashes vs. underscores in filenames




Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Tony Lawrence



Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





The whole thing that makes a mathematician’s life worthwhile is that he gets the grudging admiration of three or four colleagues. (Donald Knuth)

[This] reminds me of a quotation from somebody that, whenever he tried to explain the logical structure of a programming language to a programmer, it was like a cat trying to explain to a fish what it feels like to be wet. (Saul Gorn)







This post tagged: