Something that I intended to do last week but didn’t get covered was semantic URL structure especially as it relates to permalinks on our site. As you may or you may not know the pretty permalinks are the English or other language readable versions of your page names and in the URL.
Review Permalink Structure
For example, this is the site that I’m building right now as we go through this course and if we go to the one product page we have, the name of the site is www.thesismember.com/products/how-to-install-wordpress-and-thesis/. This is a pretty permalink. This is the semantic URL structure we want to develop. If we do the same thing in the site that we did last week, you can see that what we have instead is on exactly the same page but it is week2.thesismember.com/?page_id=20. This is the standard machine readable URL. Instead of this machine readable URL we want what Google refers to as a semantic URL. In our case, I’m just going to show you what we’re going to use for this semantic URL and then show you how it works.
So if we go back to the site and go to the dashboard, and scroll down to settings and permalinks, what we’re going to do is choose month and name. And then instead of year, month and post name, were going to copy this monthnum right there, cut it out and replace year with that. In the middle of that we’re going to add category. So the custom structure reads /%monthnum%/%category%/%postname%/. Go ahead and save changes to that.
This is what I recommend for most people because it produces this kind of URL. That is, it produces this hierarchical URL where the products page comes first and how to install word-press-thesis is the child page of products page so it stacks those up. And then it also does the same thing for posts and for posts what it will do is give the site name and then the number. That is the month number. And then the category name, and if there is a category and sub category, there will be a category, sub category and post title which is a perfectly semantic URL. And what it does for us, the reason why we insert this number, is because it makes WordPress quite a bit more efficient in deciding how to display a given post or page.
The thing is that if you don’t put a number in there, it’s relatively easy to create a URL structure from pages that would conflict with the URL structure for posts. And so what WordPress has to do then if it doesn’t see a number is it has to go through a system of checking whether not it’s trying to display a page or post. Well if we’ve got only ten pages it’s not a big deal, but in this case were not building a small site and we may have a couple hundred pages by the time the site is done. And in that case being able to indicate to WordPress whether or not it is attempting to display either a post or page is very important and adding that month number in there will do that for us. So that is we are doing. We are creating this semantic URL using this permalink structure /%monthnum%/%category%/%postname/.
Before I go too far into this, I know that wasn’t much of a conversation about permalinks, so if you have any questions about permalinks you can save them to the end and I can answer them or if you want to raise your hand here I can take the questions right now. I say a lot about permalinks elsewhere on the site and so you will certainly find a more detailed explanation of this there.
Now that we have it this way, if we go back over to our site and look what happens with this. Now when we go to the products How to Install WordPress and Thesis, we get exactly this semantic URL with week2.thesisemember.com/products/how-to-install-wordpress-and-thesis/. Marty asks for me to repeat the link. I’m assuming for the moment Marty that you’re referring to the place on the site were the permalink is set. And that is down under Settings and Permalinks and then what I did was I chose monthnum and name as a basis then I moved monthnum out of the section here and put it here and then category and then post name. So it goes /%monthnum%/%category%/%postname%/