If you’re looking for the best permalink structure for WordPress, you must also think about both SEO and speed. Ranking well in Google is of prime importance, but you don’t want a slower site because of poor permalink structure – especially since Google now uses “site speed” as one of the ranking factors in it’s search algorithm. Today we’re going to teach you what we’ve learned about WordPress permalinks over time, and how we set them up for both SEO and speed.

wordpress-permalinks-seo-speed

What ARE Permalinks?

Permalinks are the links within your WordPress website. The links to posts, pages, tags, categories, archives – all that stuff.

By default WordPress uses a system where every one of those items has an “ID” number. In your WordPress dashboard if you go to “Settings->Permalinks” you’ll find that you can change the default “permalink structure” from being ID based to more of a “pretty permalink” (one with actual words, which are more useful in search engine ranking).

wordpress-permalinks

The image above is the permalinks settings page. When you install WordPress, “default” is checked and you can see that the URL’s are www.site.com/?p=123 where 123 equals the ID of an item. If you do nothing with your permalinks, by default your website will work just fine, and all the URL’s will contain or end with an ID number like that. Over time people figured out that having the actual title of the post or page in the URL instead of the ID boosted your search rankings, and that’s why everyone wants the “pretty permalink” instead.

How do Permalinks Work?

Without getting really technical, in the most basic terms WordPress itself has to “rewrite” each URL on request (on the fly). When a request comes in for www.site.com/sample-page WordPress does some hocus pocus and matching to correlate /sample-post to the real ID in the database.

What you REALLY Need to know: Something that very few people seem to know is WordPress has about “20 rewrite rules” in a default installation. These 20 rules are for matching permalinks to posts, pages, tags, categories, author pages, etc. That means EVERY single time a URL is served in WordPress all or part of the 20 rewrite rules (until it finds the right match). When a URL is served WordPress says “ok, how do I match it – is it this, is it that”. Even though there are 20 rewrite rules, WordPress is still VERY, VERY fast – because we’re talking about microseconds here.

What “can” slow down a WordPress site is the combination of having too many paged Pages AND a bad permalink structure. Within WordPress you have (blog) posts, and then what we call static Pages (generally used for About, Contact, etc.).

If you have a poor permalink structure, then each WordPress page you create adds 11 rewrite rules (on top of the original 20). So if you have 1 contact page and 1 about page, that’s 22 additional rewrite rules. If you have 10 products and services pages, then you’ve added 110 additional rewrite rules. Once the rewrite rules get above 200+, that’s when you start noticing performance issues, so if you have 15-20+ static pages in your WordPress website – you’re at risk.

First, we should say that even if your permalink structure is bad, and causes the extra rewrite rules – if all you have is an About page and Contact page (and all the rest of your content is in posts) none of this may matter to you. Where we’re seeing problems is WordPress is being used as a fully fledged CMS for informational sites more and more (especially with small businesses). Many of these sites have 20-60 static pages of products and services, and then many are using posts as well (as a blog). That’s where you start running into problems (poor permalinks and 20+ pages).

What Are the Server Performance Issues?

The best way to describe this is to just re-post what core WordPress developer Otto had to say in a recent forum post about “Which Permalink Structure is Best?”.

This is what he had to say about permalinks and server issues:

Also, after a certain point, you start running into database server limitations. If the generated rewrite rules can’t be stored, then they have to be regenerated on every page load, which causes a thousand or more extra queries to the database server. This completely kills the site, more or less instantly. The underlying problem here comes from the rewrite rules string exceeding the mySQL max_allowed_packet size, which on many setups defaults to 1MB or so.

Future versions of WordPress may improve upon this issue, however the underlying problem will likely always remain. If there’s no easy and obvious way to tell a Page URL apart from a Post URL, then WordPress will have to create rule systems that allow it to do so in order to be able to serve webpages up as rapidly as possible.

Otto wrote a great article last year you might also like to read: “Category in Permalinks Considered Harmful

He shows some of the normal rewrite rules, and why starting permalinks with %category%, %tag%, or %author% is a really bad idea.

What is the Best Permalink Structure?

So, now that you know what permalinks are, how they work, and what the server performance issues are if you have a poor permalink structure, the next question you’ll have is – what actually is the best permalink structure?

OK, we’re going to go right back to that permalinks settings page:

wordpress-permalinks

Of course you don’t want to use default, but the second and third selections are what we call “date based permalinks”. You can go with day and name or month and name (or other variations). WordPress encourages date based permalinks, and that’s why they’re in the default options.

The whole problem with the rewrite rules are – the 11 extra rewrite rules don’t have to be added if your permalinks start with a unique random number. The random number helps distinguish the posts from the pages in the database. For example, if your permalink structure is /2011/05/15/sample-post – then WordPress knows that all your posts start with numbers (and it makes them easier to lookup via the rewrite rules). But if your permalinks are /%postname%/ (like so many people use), then the URL’s for posts and pages both just contain words, and like /sample-post and /sample-page. WordPress has to add 11 extra rewrite files for every single page in this case, so it knows that page isn’t one of your posts.

Date Based Permalinks: Let’s talk about date based permalinks for a second. Are date based permalinks the best to use? Well, they will solve the problem with WordPress and the performance issues involving all the extra rewrite rules. If you use date based permalinks and have hundreds or even thousands of pages you shouldn’t suffer performance issues. There are no significate SEO reasons not to use date based permalinks, but we’ll talk about that more below. Suffice it to say, using date based permalinks in WordPress is not a bad choice at all.

ID Based Permalinks: The often overlooked permalink setting is the fourth one “Numeric”. This is the /archives/%post_id% structure. This would result in a post being www.site.com/archives/123. This is seldom used because, as you can see, it contains no keywords in the URL at all.

As an alternative to date based permalinks you could use a custom permalink structure like this:
/%post_id%/%postname%

By using this structure, you get the post_id in the beginning (which satisfies the WordPress requirement of having the URL start with something numeric), and then you still get to use the keywords of the post title by adding postname after that.

It’s also what you see on a good majority of large non-WordPress websites as well. For example, Search Engine Watch URL’s for articles are formed like this:
searchenginewatch.com/article/1234567/article-name-goes-here

WordPress Permalinks and SEO

This whole business with “pretty permalinks” started years ago when people found out that having keywords in their URL gave an additional boost in search rankings. It started with people using simply /%postname as their permalink structure, but over time in some SEO circles it was found that /%category%/%postname% could also be beneficial. Some people swear by it.

About /%category%/%postname% and SEO: Our opinion on /%category%/%postname% is that if it once worked – don’t count on it anymore. The reason is that the Google Panda Update (also known as the Farmer update) has completely changed the game in SEO. What started at first as Google algorithm changes to filter the effects of low quality links in ranking, have now led to what we call “over-SEO” penalties.

The easiest way to explain this is – Google knows when you’re trying too hard, and when you are – you’ll get a penalty for it. Google has never liked tag or category pages, because they’re just yet another regurgitation of your existing posts, sliced and diced in different ways – with no additional original quality content. Why would they like you adding category names before the URL’s of bunches of posts in an attempt at better rankings? The category postname permalinks worked better when Google wasn’t specifically looking for people overdoing SEO (and now they are).

So, if you’re going to use category postname, just know that in a post Panda world – Google might not like it. That AND, if you do use it you’ll have the performance issues noted above.

About date based permalinks and SEO: Hardcore WordPress proponents push date based permalinks because they solve the performance issues, but since they’re (usually) not marketing people – they don’t always understand exactly why many people don’t like them.

Once you publish a post with a date in the URL – it’s there for good (unless you change your permalinks in the future, and redirect all those post). For a news based site, maybe you don’t care if your posts are dated – because date determines relevance. But if you write marketing material on your blog that you feel would be useful for years – you may not want to “date” it for fear in the future people would overlook it – because it was old (even though the information is still valid). Other people feel that when the date is in the URL Google may give newer articles preference, shown by the fact search results themselves contain dates, and the newer articles are always towards the top. Some argue that even with no date in the URL, Google still knows how old your content is from the XML sitemap or first time it was crawled and indexed.

Google uses more than 200 “ranking signals” in it’s algorithm when determining who comes up for what in search results. We have not seen evidence of using or not using a date based permalink affecting SEO in such a way to say it’s better or worse. It’s a personal preference, and it does solve any of the performance issues listed above.

About numeric permalinks and SEO: From a pretty permalink perspective, if you go with the default /archives/%post_id% you aren’t using any keywords, so it doesn’t help SEO at all. That’s why we prefer /%post_id%/%postname% – which gives you the best of both worlds. You get great SEO, without having to worry about any site performance issues.

Another side effect is, if you want to get indexed by “Google News” – they require you have a numeric identifier within your permalink structure at least 4 digits long to be indexed there (but either date based or numeric permalinks would be acceptible).

What’s the best permalink for SEO then?

In our opinion it’s either date based permalinks or /%post_id%/%postname%. If you’ve been using %postname% for years or %category%/%postname% and you have few enough pages where you don’t have performance issues – stick with what as long as you have no issues.

Permalinks and Speed

We talked about the performance issues you can encouter with poor permalink structures, and SEO benefits as well. It’s obvious that if you have a poor permalink structure AND more than 15-20 static pages in WordPress, you can start having site speed issues because of all the rewrite rules.

What we didn’t mention (up until now) was that this is how WordPress operates “out of the box” (without any caching). For example, if you’re using WP Super Cache your WP website is cached to static HTML files anyway. You might use WordPress with a CDN and a plugin – like W3 Total Cache. So if you were having performance issues because of poor permalink structure, you may be able to aleviate that just by caching your site or using a CDN.

What we can tell you is this – website speed is definitely a ranking factor that Google now uses. This year they also made available the Google Page Speed API, which many SEO and caching plugins for WordPress are now using.

So, when it comes to permalinks and speed, just make sure you’re not using the poor permalink structures above that cause performance issues. Then cache your site when possible, and use the Google Page Speed API tools in your caching and SEO plugins to make sure you’ll optimized as much as possible.

Conclusion on WordPress Permalinks

Hopefully you’ve learned a thing or two today, we know that our view on permalinks has changed over the years based on experience, updates to WordPress, and plugin functionality. As Otto wrote in his excerpt, future versions of WordPress may well fix the performance issues with static pages and rewrite rules, but at least for now you know what they are – and your options for best permalink structure.

Also consider visiting the Official WordPress: Using Permalinks page for detailed information on all the options available.

ALSO: We know for a fact that there will be people that read this post and say “see I KNEW WordPress wasn’t a CMS, Drupal and Joomla beat the s*$^ out of it…”. They will base that on the fact that with the permalink issue, you can’t create a lot of static pages without having performance issues.

Well, one thing we saved for yet another tutorial is – how to NOT USE WordPress pages at all for hierarchal or custom content, and instead using the WordPress 3.0+ feauture of custom post types and taxonomies. WordPress IS a fully functioning CMS – and you should probably read our How to Create Custom Post Types in WordPress tutorial next!