Skip to main content

Pros and Cons of Semantic URLs

Semantic URLs have some great benefits. The most obvious one is SEO-friendliness (search engine optimization - Google simply likes semantic URLs better). Not only that but users tend to prefer semantic URLs when they come up in search results.

However, assume for a moment that you're the user and you want to re-post a specific article...is it really a net benefit to make a longer URL like: http://www.dogs.com/articles/wiener-dogs-do-super-cute-things-when-you-play-with-them versus http://www.dogs.com/articles/158? You may have made a trade-off here: SEO-friendliness versus ease of use. As a user, you probably already know the URL you are looking for, so that part is easy. You probably can guess that articles are under "/articles", so that part is easy as well. So sometimes it comes down to which is easier to use - a super-long article "slug" or a simple number. Ask yourself what happens when you want to send the link via text or Twitter or some other text messaging service/ You're probably going to appreciate a shorter link so you don't have to plug the URL into a URL-shortener service like bit.ly in order to keep your message brief.

Of course, the disadvantage may lie in the fact that numbers are not obvious. If you read a lot of articles on a particular site, you will have a lot of numbered links in your history to contend with. Good luck finding that one article you saw about super-cute wiener dogs when you have a bunch of similar links with article numbers! That said, you could always bookmark a page you like and call it whatever you want (which is actually the preferred behavior, but I digress...).

Ultimately, you need to be smart about your semantic URLs. Realize that search engines are NEVER going to be able to index any pages behind a login, so for sure you don't need semantic URLs there. Realize as well that super-descriptive URLs may not be helpful to your user in some cases where the URL may get shared. Also consider that if you aren't a really popular website that publishes a bunch of daily content, it really may not help much to be very descriptive. Also, you're going to need some additional code to check that your descriptive strings are unique and generate a new one if it isn't. Also, storing a long article "slug" means using more storage in your database.

I'm not saying semantic URLs should never be used. They are definitely appropriate for certain sites and circumstances. Just realize that they are not a panacea and you may actually be shooting yourself in the foot when you insist on using them for every situation.

Comments

Popular posts from this blog

jQuery noUIslider Pip Label Customization

Recently, I was tasked with creating a slider element for a user to select their credit rating, of which the user can select from among: 'Poor', 'Fair', 'Good', 'Excellent' and 'Not Sure'.  Several problems presented themselves here: A drop-down box would be better, but that's not what the requirements specified. I already have several numeric sliders on my page and I want them all to match. I selected the jQuery noUi Slider library to create the numeric sliders. noUi Slider does not support string values - only numeric values. The "pips" (slider scale/labels) also does not support string values. Since the solution involved shifting my mindset, I wanted to document it here for future reference and maybe to help someone facing the same requirements. Here's my solution: Since there is really no numeric correlation to credit score (especially considering one of the options is "Not Sure"), I will just u...

Salesforce Apex: Replacing and/or Removing Apex Classes

Working with code within the constraints of Salesforce's workflow can be a challenge.  First , you have the restriction on changing anything in production.  Second , you have the requirement for 75% or greater unit test coverage.  Third , you have the fact that certain metadata cannot be pushed to production through a changeset (which means the only way to sync record IDs is by re-deploying the development environment from production). Fourth - and this is what I'd like to blog about today - you cannot delete classes from production through the Salesforce UI .  The only way to delete a class from production is to download the class (and its associated metadata file) into the Eclipse IDE (which you have previously set up with the Apex add-on), change the "status" flag to "Deleted", then deploy the changed metadata file to production.  And (here's the kicker)...sometimes it doesn't work because...reasons. So let's start with the workflow of a f...

More Laravel Magic - Touches

What is "touches"?  Well, anyone familiar with Linux/Unix is going to be familiar with the concept of "touching" a file.  Touching a file sets the "last modified" timestamp (or creates the file if it doesn't exist).  Knowing when a file was last modified can be very important for version control. Laravel has something similar for its model relations.  For example, lets say there is a club with many members.  When a member joins, leaves or gets a new role in the club, you might contend that the club has changed.  In terms of Laravel, you would want the club table's "updated_at" timestamp to reflect that change.  Enter the "touches" property... To make the magic happen in Laravel, you simply need to define the parent relationship and add it to the touches property like so: <?php class Club extends Model { /** * Touches (touch parent model when this model changes) */ protected $touches = [ ...