Hyphen, underscore or space? Which one is the best for SharePoint Search?

Hyphen, underscore or space? Which one is the best for SharePoint Search?

I was at a client today and I got a very interesting question about how should users name their files. There were many rumors that underscores were the best, since SharePoint knows to split the words up after an underscore. I didn’t have an immediate answer about it, but let’s test it out!

I have uploaded three files to SharePoint with content that makes no sense, so the search only searches on the title of the file. Here are the names of the three files:

  • Vlad is the best SharePoint Administrator ever
  • Vlad_is_the_best_SharePoint_Administrator_Ever
  • vlad-is-the-best-sharepoint-administrator-ever

 

So, after 30 minutes, I decided to search “SharePoint Administrator” without the quotes! Here is the result:

best SharePoint Search

As you can see, all 3 results have been returned, however the only difference is that SharePoint was able to find the two words in the URL as well for the “Space” and “underscore” options!

Now let’s try with quotes around “SharePoint Administrator”. We can see that the results are similar to the one before, however only the result with a space was bolded by SharePoint. SharePoint found the word with a space in the URL, even if there was a space or underscore.

best for SharePoint Search

However, if we search for “SharePoint_Administrator” without the quotes, we only get the one that actually has the underscores in the title name!

However, I have never seen anyone actually use underscores when doing a search. But if your users do it, it’s a good to know!

Conclusion

After testing, I believe that spaces are the best option for your filenames, but if you really don’t want to use spaces in your filenames, use underscores! Never use hyphens!

 

Leave  a comment and don’t forget to like the Absolute SharePoint Blog Page on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  Also, don’t forget to check out SharePoint Community.Net for more great SharePoint Content.

5/5 (1)

Please rate this

 
Comments

Did the time you uploaded these 3 files play into the ranking and results? It seems like it would. Could you share the time stamps or order you uploaded these? I agree spaces should be best.

Hey Joel!

All 3 of them were uploaded at the same time, so timing didn’t make a difference!

Good to know, thanks for sharing!

Hey Vlad, leaving the space adds the three extra characters into the URL for each space, correct? So if you are concerned with reaching that maximum 255 character length of the URL, it would be best to use the underscores. Would you agree with that statement? On my department’s intranet site (SharePoint publishing platform), I have been removing spaces from file names whenever I find them for that reason. Our site was built in the traditional sub-site architecture rather than across one level, and the number of characters in the URL is very important. It has impacted us with retreiving site metrics from Adobe reporting and analysis (Site Catalyst). Thanks!

Hello,

As many people on the comments said, and I agree with them, it may cause problem with the URL Length. However, since you’re not supposed to use folders in SharePoint, but more metadata, you shouldn’t reach the 256 characters that easy!

If you use a lot of folders or a lot of subsites, I agree that underscores would be the best option!

What about the issue with the url string not exceeding 256 character? i’ve been to that once a url string exceeds 256 characters SharePoint begims to experience degradation. for example if you are in a site and your url path is /sites/People%20Places%20and%20Administration/Employee%20Communications%20Team/This%20is%20a%20long%20filename.docx couldn’t doing your recommendation become problematic?

Hello,

As many people on the comments said, and I agree with them, it may cause problem with the URL Length. However, since you’re not supposed to use folders in SharePoint, but more metadata, you shouldn’t reach the 256 characters that easy!

If you use a lot of folders or a lot of subsites, I agree that underscores would be the best option!

Hi,

Again, just like others, spaces add the special encoded chars in the URL; adding to the length of the URL but also making the URLs look ugly too for sharing etc. when applicable.

Why do _ and – not work in the same way, is there a way to configure this somewhere may be?

Also, no matter how much metadata you use, a big intranet/collaboration setup will have few levels if not many, and spaces will make if look totally unacceptable almost?

Thanks

Also, the key is that SP recognises the -hyphen and hence searches for those words entered in the search, even if they are typed separately. You could still search for SharePoint or Administrator, and SP would list the file with -hyphens in it too.

The bold text is via the use of XSLT as per my understanding so a bit of tinkering should do the job I’d imagine.

Will be good to hear what others think and their views ?

We are crawling File Shares as well so does the recommendation hold there as well?

Why isn’t camel case one of the options considered?

Didn’t think of it and I haven’t seen it as a popular options in my clients. Do you have a lot of clients that use camel case as a naming convention?

Nice post Vlad!

I am concerned with the issue of me just learning I am not the best SharePoint administrator in the world…. Other than that, nice post.

Did you try just searching for one word (as opposed to two words — SharePoint Administrator) like either SharePoint or just Administrator?
I have observed, when using Two or more words, results are correct… But if using just one word as keyword, then results are not correct. Any pointers?

What about comparing to VladisthebestSharePointAdministratorever?

Leave a Reply