making sense of the senseless

Create Short and Clean URLs

URL naming in our CMS is currently a little tricky. If you just create a new page naturally using the CMS, without putting much thought into how the back-end code is working, you can get some really funky page names that can sometimes be the opposite of what you want. Before I dish out the goods, let me quickly explain not how, but why the URLs are created the way they are.

Perma-what?

Somewhere, sometime in the past, web developers realized that websites can get really huge. Especially e-commerce sites and blog sites. In fact, especially blog sites. You can get hundreds and hundreds of blog posts. All these blog posts are stored in a database somewhere and each one has an id number. In order for a user to find a post, they might type in a URL like: http://www.someblog.com/posts?ID=54. This link might bring up the post with the ID of 54 from the database and display it on the page. That is simple enough. It sure beats actually creating 54 different pages. You can just create one page and pull the content from a database.

However, remembering the URL is not as easy, and surely not as neat and clean as something like http://www.someblog.com/posts/learn-about-permalinks. You can surely remember “learn-about-permalinks” better than you can remember ID=54 especially because “learn-about-permalinks” has more meaning. Also to a search engine looking for pages that have to do with learning about permalinks, this URL is much more friendly and informative than ID=54. So web developers came up with this term: Permalink.

A permalink is just that. A permanent link to a resource, and usually by design easier to remember than regular URLs. Granted a URL is a permanent link, but this term permalink was coined for bloggers so people could search, scan, and find relevant articles easier than reading through a bunch of id numbers. Our CMS tries to help in this aspect by creating human readable permalinks to all pages that are created, but it fails in one aspect. Most content management systems, including the one I am using, allow you to edit the permalink on the chance you don’t like the one the system comes up with. Ours does not, but there is a work around, so let’s get to it.

The How To

The easiest way to get a nice clean permalink only takes a step or two more than the normal process for creating a new page. First of all, decide before hand what the page name is going to be as well as what you think a good permalink should be. Changing it afterwards is harder sometimes, especially if you already have pages linking to the page you want to change the permalink to. So for my example we are going to pretend that we are creating a new page for the student government, ASUSU.

Now, when you are making the link to this new page you may want the link to read: Get Involved with ASUSU today. That’s great link text; descriptive, inviting, exciting. It’s not really great permalink text. If you were to make your new page using our CMS and that link text, your page would probably be something like this: distance.usu.edu/get_involved_with_ASUSU_today.

Yikes. Who would want to type that in their browser? No one. So using the following steps you can clean this up.

If you are making the previous page and want the permalink to be distance.usu.edu/ASUSU, than make your first link text ASUSU and create the page.

Build the page as you normally would giving it content, a title, a custom left navigation if you want, and POW! You’re done with your new ASUSU page.

Go back to the page where you made the link to that new page and delete the original link.

Create a new link in its place that reads: “Get Involved with ASUSU today!” and link it to an existing page.

Choose your new ASUSU.cfm page and hit save

You have now preserved your beautiful inviting link text as well as your friendly permalink distance.usu.edu/ASUSU. Students will thank you for such a nice URL to type in, and on marketing pieces, fliers, announcements, etc you have a nice short URL to use. Piece of cake.

Even Simpler Than That

What if we want to get rid of that pesky .cfm at the end of the URL. Here we are a bit limited by our CMS. In most if not all main stream CMS’s that I have used, you never have any file extension text. This is because ALL content is stored into a database and pulled using permalinks and displayed using a single or sometimes a small group of files. Our CMS actually creates individual pages for all content and therefore the file extension is required. There are some plugins that may be able to remove this but it would require site-wide updating of links and just more work than it would be worth.

I have mentioned this to a few of you before, but sometimes it makes sense to create a new section of your website as I recently did with our ASUSU information. That way all the content can be stored in that section, the URLs relate to one another, its a bit more SEO friendly, and just better practice. It’s also very simple for me to do. Imagine the following structure of content.

distance.usu.edu/ASUSU

distance.usu.edu/ASUSU/calendar.cfm

distance.usu.edu/ASUSU/signup.cfm

distance.usu.eduASUSU/contact.cfm

Now try to imagine that same site structure but without the same folder structure.

distance.usu.edu/ASUSU.cfm

distance.usu.edu/ASUSU_calendar.cfm

distance.usu.edu/ASUSU_signup.cfm

distance.usu.edu/ASUSU_contact.cfm

Not only is there no hierarchy to the content, but the URLs look strange with the _ character in them. Also these are more search engine friendly. A google-bot would know that there is a section of the site called ASUSU and the sub-content is related to that site. It might event show ASUSU as a section within a users search results because this hierarchy exists. It is also not only good, but the correct practice when developing sites. Think about trying to move content from one site to another or to another CMS and all your pages look something like this.

distance.usu.edu/ASUSU.cfm

distance.usu.edu/calendar.cfm

distance.usu.edu/ASUSU/calendar.cfm

distance.usu.edu/election_sign_up.cfm

distance.usu.edu/candidate_info_for_ASUSU.cfm

Even with descriptive information in the permalinks, the structure helps define what pages are related to what. It makes is easier when editing back end files or data as well. The goal in the future is to move us off of this CMS and onto a third-party CMS or something with more flexibility.

The bottom line as far as site structure goes is that if you need me to create a section for part of your site I can easily do that. That way you can have more flexibility with your structure and organization as well as easy to read permalinks. You can have two contact pages that are simply contact.cfm. One in your root directory and another possibly in a sub-directory which makes for good practice.

In Summary

While our CMS doesn’t allow for great flexibility in creating easy to read URLs/permalinks, it can be done. Just use the tips above when creating new pages or sections and you won’t have to deal with distance.usu.edu/really_long_urls_anymore.cfm.