Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best character to represent blank spaces in a URL?

Tags:

url

seo

When you are building URLs that should be legible for users and search engines and you do it automatically from the content, what's the best way to represent blank spaces? Hyphens (this is what StackOverflow uses)? Underscores? Any other? Does any of those make a different for SEO?

like image 646
pupeno Avatar asked May 30 '09 08:05

pupeno


People also ask

How do you represent a space in a URL?

URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits. URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.

Why space is not allowed in URL?

The space character is unsafe because significant spaces may disappear and insignificant spaces may be introduced when URLs are transcribed or typeset or subjected to the treatment of word-processing programs.

Should we use spaces in Uri?

The whitespace should be ignored when the URI is extracted. For robustness, software that accepts user-typed URI should attempt to recognize and strip both delimiters and embedded whitespace.

How do you handle space in Uri?

Change the Path on the Filesystem If changing the filesystem is an option, the easiest solution is to simply to change the filesystem path to avoid white spaces, allowing the in-database URIs to match. If the filesystem path doesn't have spaces, MLCP won't need to adjust the paths to make them match.


2 Answers

Both are valid URL characters and both have their pros and cons.

Pro dash

  • Google recommends dashes, and here is what Matt Cutts from Google has to say about Dashes vs. underscores.

    If you have a url like word1-word2, that page can be returned for the searches word1, word2, and even “word1 word2″. That’s why I would always choose dashes instead of underscores.

  • Dashes seem to be what major blogs do: The Huffington Post, TechCrunch, Engadget, ...
  • Dashes seem to be what major CMS do.
    Not sure about that one anymore, can anyone comment?
  • As mentioned by Kazar, underscores can clash with the underlining of links.
  • I find underscores awkward to type.
  • Rene Saarsoo pointed out that dashes take less space than underscores in proportional fonts.
  • Ionut G. Stan mentioned that underscores are not allowed in hostnames. If you strive for consistency you should opt for dashes.

Pro underscore

  • Dashes are not allowed in ISO9660 file systems. This can be a problem if your content is also shipped on DVD or CD (e.g help files or eLearning content).
  • In some languages (e.g. German) dashes can be word characters and are not generally considered word separators.
like image 58
13 revs Avatar answered Oct 02 '22 07:10

13 revs


Another advantage of dashes is that in proportional font they take less space that underscores. Compare:

  • https://stackoverflow.com/../whats-the-best-character-to-represent-blank-spaces-in-a-url
  • https://stackoverflow.com/../whats_the_best_character_to_represent_blank_spaces_in_a_url

It's not a lot, but every little helps :)

like image 31
Rene Saarsoo Avatar answered Oct 02 '22 07:10

Rene Saarsoo