WordPress Permalinks Tutorial

What are permalinks and how to use them

Each post, category, etc. on your blog has a URL which used in a browser opens the particular post or category. This URL is used by others, or you, to provide a link to an article, post or list of posts on your blog. So it helps if this URL is easy to remember, to use and, not least, if aesthetically it looks good. The URL that you see in your browser for a particular post (or something else on your blog) is also its permalink.

Permalinks are called like this because they are permanent links to your site. They don't change unless you change their structure. You can do that from the Permalinks section of your Dashboard.

The default permalinks have a combination of numbers and question marks in them. For example, a permalink to a post on your site might look like this:

http://yourdomain.com/?p=16

This link structure makes it difficult for people to orientate. From your Dashboard you can change how the permalinks to your site look and create what's called pretty permalinks. You can make them look like this, for example:

http://yourdomain.com/2011/06/postname

This looks more meaningful to people and, what's more, just deleting the post name (http://yourdomain.com/211/06), for example, would display a list of the posts for the month of June. So such a link is much more convenient because users can navigate through the archives of your blog by just changing the number for the month or year in the URL, whereas the default permalinks don't really make much sense to people. This is just an example of what a pretty permalink might look like.

There are some server requirements in order for pretty permalinks to work. All HostKnox servers meet these requirements, so you don't have to worry about that.

If you want to use pretty permalinks instead of the default ones, log in to your Dashboard, click on Settings on the left and from the submenu click on Permalinks. On the Permalink Settings page you'll see that the Default button is checked, and right next to it there is an example of a link with a default structure. Below it there are several other buttons (Day and Name, Month and Name, Numeric) which give you the opportunity to use different permalink structures. For example, if you check the button Day and Name a link to your posts will look like this:

http://yourdomain.com/2011/06/15/postname

There is an example for each button on the Permalink Settings page, so you won't find it difficult to see what the link would look like.

Notice the last button Custom Structure. Notice how when you check any of the above buttons in the Custom Structure field appears a combination of tags. For example, if you check the Month and Name button, in the box next to Custom Structure you'll see the following combination of tags:

/%year%/%monthnum%/%postname%/

These tags describe the Month and Name permalink structure. If you want to, you can create a custom structure by checking the Custom Structure button and typing your own combination of tags.

N.B.! Don't use a URL address in the Custom Structure field. You should only use tags as the ones shown below.

Here are some tags you can use to make a custom permalink structure:

%year%

%monthnum%

%day%

%hour%

%post_id% (each post hast its own ID number, e.g. 16)

%postname%

%category%

%author%

They are all self-explanatory. So, for example, if you want the URLs to your posts to contain the month and post name (e.g. http://yourdomain.com/06/post), you should type the following tag combination in the Custom Structure field:

/%monthnum%/%postname%/

Another thing to remember when making your own custom permalink structure is that it is not recommended to put at the beginning of the structure the tags: %postname%, %category%, %author%, %tag%. Structures beginning with these tags need more server resources and might slow down your blog.

Once you have chosen any of the permalink structures, or created a custom one, you have to click on Save Changes at the bottom of the Permalink Settings page. WordPress will try automatically to write the rules for the new permalinks in the .htaccess file in the root WordPress folder. It's possible, if you haven't used permalinks so far, that you don't have such a file. WordPress will try and create it automatically.

Probably you won't have any problems but you may have to create the .htaccess file yourself; you can create it in advance anyway. An easy way to do that is through the Files section of the HostKnox control panel, through SSH, or you can create the file on your computer and upload it through FTP. Don't forget that the .htaccess file has to be in the root WordPress folder (e.g. public_html/wordpress).

If you have an .htaccess file but it's not writable, you'll receive a message “You should update your .htaccess now” and at the bottom of the page another message providing you the rewrite rules which you have to copy and paste inside your .htaccess file yourself. You can open and edit the file using the HostKnox control panel or your favorite FTP client.

Once the changes are saved your blog will operate using the new permalinks.

On the Permalink Settings page of your Dashboard there are also the optional settings to change the default URL structure for your category and tag archives. The defaults are category and tag. Which means that, for example, if you have a category on your blog named category1 then the URL link to its archive would be:

http://yourdomain.com/category/category1

This will display the archive of all the posts in this category. If in the field for the option Category base you type topics and you save it, then the URL address would become:

http://yourdomain.com/topics/category1