Twitter: lunch with my freshman year roommate.

The Importance of Permalinks

Apr 03, 2006 in ,

In the past few months I have setup and helped others install and configure WordPress blogs many times. One of the more frequent questions I get pertains to this page in the WordPress admin labeled permalinks. The easiest way to describe permalinks is by saying that they are pretty URLs. For example, enabling permalinks on your WordPress blog changes http://www.yourdomain.com/index.php?p=102 to something like the following URL: http://www.yourdomain.com/2006/04/30/apple-releases-ipod-micro (although permalinks can be setup to display in various formats).

Technically Speaking

Permalinks work by adding an entry into a .htaccess file, which lies at the root public html directory of your server (this might be a folder named httpdocs, www, public_html, etc. - it should be obvious). This is a powerful config file or “distributed configuration file” that can carry out actions in the Apache webserver on a per-directory basis. Permalinks usually rely on mod_rewrite, part of Apache, to turn the post ID URL into the nicer URLs you see on this site. Below is what the typical .htaccess file for a permalink-enabled WordPress blog looks like.

# BEGIN WordPress
<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</ifmodule>
# END WordPress

I don’t want to delve into the world of .htaccess hacking but I will mention that if you add to it, such as making a custom error page, make sure to have that outside of the # WordPress tags completely. Anything in between those two will get overwritten anytime you add a page to your blog or make changes in the WP admin affecting permalinks (hat tip to Kristin for the reminder).

Set Them Up

Before I go about professing the sheer joys of using permalinks, let’s make sure your blog can strut permalinks. Login to your server and navigate to the aforementioned public web directory. Make a new, blank plain text file (none of that .rtf or .doc stuff) in that directory and label it .htaccess; the dot is very important. You might need to have your FTP client set to show invisible files or not hide them - a quick peek in the options should solve this. Now right-click on this file and select get info or some option with chmod, this varies by FTP client so I can’t cover all the bases. We are going to want to perform a chmod 777 so that we can change options in WordPress and let it have the ability to write to the file. Once you have done that, login to your WordPress admin and go to Options » Permalinks. You will be confronted with a few options as to how you want to format your permalinks. The most widely used format is date and name based, however you can pick whichever you like. When you’ve selected the format, just click on Update Permalink Structure. Now go back to your FTP client and perform a chmod 644 to ensure that nothing bad can happen to your omnipotent .htaccess file from outside sources. You’re done!

If you receive any Error 500: Internal Server Error, this is most likely from a botched .htaccess configuration. Go back and ensure that your file was chmod 777′d before enabling permalinks and then try it again. Other sources of this error can arise from a reluctant server or one that doesn’t support mod_rewrite in Apache.. or your server doesn’t even run Apache. In this case, a visit to the WordPress Codex is in order for setting up permalinks in your special case.

Come On, Enlighten Us Already

Permalinks encourage website browsing. From a millisecond glance at a link to your permalinked blog, the user knows how recent the post is and its title. That is a lot more than /index.php?p=102 could ever convey. What if a user follows a permalink to your site only to find that you have since removed that article or changed the post slug (the last part of the permalink with the title)? They can simply navigate your archives by manipulating your URL. For example, going to http://www.paulstamatiou.com/2006/01 produces an archive page letting the user browse all of the posts I made in January, 2006. Want to see what post I made on January 21st, 2006? Just add /21 to the end of the URL.

Permalinks are vital to a successful blog. By only remembering the date of a post, people can easily spread the word about a particular post of yours. Permalinks also work for categories and tags. You can see all of my posts in the software category with a URL formatted like http://www.paulstamatiou.com/categories/software/. Also, since the actual post title is within the link itself, search engines pick up your link faster and can provide your link in higher search rankings. Tom Raftery goes more in-depth about the relationship between SEO and Permalinks.

Promote this article on various sites or email to your friends:     



22 Comments

  1. I would do this, and originally had my permalinks nice and neat looking, but I’m dependant on StatTraq for my decent stats. And for some reason, it stopped picking up on post counts. I don’t know what happened, but realized it would only work if I put it back to default. My host said there was nothing different on his end, so I don’t know. I’ll get my permalinks pretty again when some circumstances change.

  2. Fabulously in-depth article Paul - well done.

    Thanks for the link love too!

    Tom

  3. I’ve been missing out on this for a while. I might just try it later if my htaccess file isn’t too messed up already! :P

  4. so what’s the down and dirty for someone who ahem is using the less than appealing permalink structure wishing to convert to the more appealing and understandable plink structure that’s mentioned in this post. how would someone go about changing the structure without breaking incoming links that are still using the old?

  5. I’m not sure if I’m ignorant, but doesn’t Wordpress let you easily change the permalink structure without hand-editing the .htaccess file? You can find it in Options -> Permalinks.

  6. Great post; I don’t know why I had never bothered to do this before.

    To the person who asked… no, WordPress can’t do it without editing your .htaccess file. It’s pretty close, though — it will tell you what to include, and if your .htaccess is writeable (which I’m not sure is a good idea), it will actually do it for you. So in that case, yes, you don’t need to do anything, but the .htaccess is still being altered.

    Thanks, Paul.

  7. You can also use the Nice Search plugin to make your search URL’s nice.

    e.g. /?s=hello+world, it’s /search/hello+world.

  8. Hey there,

    I had done some research on permalinks and found that you could actualy give them a .htm extention to make them look like actual pages.

    You can see my post here

  9. Yes, I know about giving the permalinks a file extension. The WordPress Codex page I linked to talks about it. However, it is purely aesthetic and holds no real semantic value. As in, the page is not really HTML, it’s still a concoction of php. I’m not too certain that Google will think of a page any more or less highly with or without such a file extension.

  10. As far as my understanding of what Google gives priority to - they give priority to a page in the root of a site over a folder that is off the root.

    Example -

    site.com/post-title.htm

    would be higher priority then

    site.com/post-category/post-title

    - Dan

  11. Good point Dan. However with the /post-title.htm, you lose the advantage of knowing when the post was made, unless that is incorporated in the name.

  12. But if i’m not mistaken, permalinks are now taken care of by Wordpress and not by apache anymore? atleast that’s what i was hearing when i asked questions like “why don’t my live archives work with the new permalinks, while they did work with the old?”

  13. I would love to use the permalinks like you describe but when I changed it in my Wordpress settings it all seemed to work fine until I realized that my Archives links were all broken. In other words, clicking on a previous month gave me Not Found pages. I never could figure out why. I’m also sure that my .htaccess file was and is editable and I’m on a Linux/Apache server at Godaddy.com

    Any suggestions?

  14. Thank you Paul for your article.

    My blog is on blogger so I will have to search a little more for help…

  15. Thanks Paul, just set them up :-)

  16. I need some help with my permalinks. I don’t know the first thing about .htaccess and the code behind all of this permalink-stuff. So any help would be apprecaited.

    I’m currently using the default WP permalink structure.
    I’d like to change the structure to: /%category%/%postname%/

    When I change the structure in the permalinks admin panel and I test the pages, I get what appears to be the main page of my site. (for example, the comment now box doesn’t appear, and there are other posts on the page).

    Any ideas what might be causing this?

  1. [...] Paul Stamitou is a 19-year old Sophomore at the Georgia Institute of Technology. I found his site from a technorati link a couple of months back when he wrote a nice piece on how to create a nice blog header graphic. The fact that I haven’t changed my theme yet to include this allegedly easy to create new header is my fault not his. He writes intelligently about great geeky topics that help me understand. Today he’s got a piece on Permalinks in Wordpress. This one I’ve figured out already (yay me), but maybe all those folks who end up with headlines that say nothing but “Permalink” on my Technorati RSS feeds will take a look and figure out how to configure their admin panels for better effect. Hey Paul, thanks for all your virtual help–I appreciate the blog and the info! [...]

  2. [...] WordPress expert Paul Stamatiou has written a concise outline of the importance of permalinks. The first half is a tech focus; then we come to the easy-to-understand bit: [...]

  3. [...] Ahora con Permalinks! April 7, 2006 Buenas, acabo de hacer el paso del sitio, desde el predeterminado de Wordpress hacia Permalinks. Me cabecee, pero me demore menos de lo que esperaba (como 45 minutos). Hace tiempo que lo quería hacer, pero no me había atrevido. Pero ahora lo hice y no es tan complicado (un cambio aquí, otro allá), aunque me costo con las paginas (Contactame! y ¿MaRcIaNo@5?). En fin, los que le peguen al inglés, lean esto, si no, siempre es útil el traductor a mano [...]

  4. [...] The Importance of Permalinks “The easiest way to describe permalinks is by saying that they are pretty URLs.” (tags: blogging101) [...]

  5. [...] The Importance of Permalinks “The easiest way to describe permalinks is by saying that they are pretty URLs.” (tags: blogging101) [...]

  6. [...] common knowledge that Wordpress is built with SEO in mind, especially if you turn on permalinks. The title tag can be automatically optimized for search engines, and the URLs produced are also [...]

Post a comment, receive Stammy points.


Send a trackback.


  • If you plan on posting code, run it through Postable first.
Copyright © 2005 - 2008 PaulStamatiou.com  Privacy Policy - Terms of Service Can't spell my name? Use PSTAM.com. Go back up ↑.