News Stay informed about the latest enterprise technology news and product updates.

Why you should make kebab case a URL naming convention best practice

They say there are only two difficult challenges in the world of computer programming:

  1. Synchronizing the invalidation of a distributed tertiary and quaternary cache; and
  2. What to name things.

Given the number of problems I encountered when perusing the Internet with an older Firefox browser, it would appear that when it comes to URL naming conventions, the second issue remains a significantly greater problem than the first.

Let’s explore this problem, and why I feel that kebab case should be the go-to for URL naming conventions.

URL naming best practices

When you name a URL, the best practice is to keep it entirely lower case. If there are separable words in the Uniform Resource Identifier which follows the domain name, separate those words with dashes. These two elements should be the cornerstone of every URL naming convention.

On the flip side, these are some of the worst URL naming practices:

  • Never include spaces;
  • Never include special characters;
  • Don’t use camel case;
  • Don’t use snake case;
  • And never, ever use screaming snake case.

Good and bad URL naming examples

Kebab case is the gold standard when it comes to URL naming. Here’s an example:

www.example.com/this-is/a-nice/url-name //kebab case

Now that you know what a good URL looks like with kebab case, here are some bad examples that developers sometimes use:

www.example.com/this_is/a_bad/url_name //snake case
www.example.com/ThisIs/aBad/URLName    //camel case
www.example.com/DO_NOT/EVER_DO/THIS    //SCREAMING_SNAKE_CASE
www.example.com/this is/going 2/cause problems  //using spaces

Why URL naming conventions are important

I’m fully aware of the fact that my complaints on website addresses that violate URL naming conventions and standards is not a persnickety pursuit. When I surf the net on an older browser within an older Ubuntu image, I noticed a number of images and SVG icons wouldn’t render properly. When I inspected the page, I noticed that the image was referenced with a combination of upper-case and lower-case letters, while the image on the server was all in kebab case.

Modern browsers will adjust for that, so it had no doubt slipped past the site’s quality assurance team, but it made for a rather horrible experience on an older one. And what’s more, it’s a problem that would have easily been avoided if the developers had just stuck with a simple and consistent URL naming convention and strategy.

This convention is not only important for website URLs and image paths. The same standards should be made part of every organizations REST URL naming and microservice URL naming best practices.

What to name things is actually a hard thing to do right. But it’s not that hard when it comes to URL naming. Stick with lower case letters and kebab case. Your site’s users with older browsers will thank you for it.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

SearchAppArchitecture

SearchSoftwareQuality

SearchCloudComputing

SearchSecurity

SearchAWS

Close