WordPress Permalinks for SEO and Speed

Posted by jtpratt |15 Jun 11 | 14 comments

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!


14 Responses

  • Thao/ 15 Jun 11 @ 7:17 PM

    Impressive article JT. I’d already read Otto’s post (several times) about permalink performance, but –like many– I was still prioritising my SEO/marketing aspects above that of the possible negative WordPress performance, and have always stuck to my category/post-name type of permalink structures.

    This article has reinforced the importance, but more importantly, I knew nothing about the Google News URL rules! So if I can boost performance & get more indexation, I’d have to be stoopid to ignore it any longer.

    So I’m thinking of using a fixed/absolute 4 digit prefix on the WordPress permalinks. This would meet Google’s News rules, plus boost my site performance, while also maintaining a “current” information look/feel: I’m going to simply use the current year (2011) and I can easily change it come 2012 (and WP will handle all the rewrites).

    This is my proposed permalink structure …
    Custom Structure: 2011/%postname%

    And come Jan 1, 2012 I will simply reset the permalinks to …
    Custom Structure: 2012/%postname%

    Any thoughts/problems with this idea?

  • admin/ 15 Jun 11 @ 8:05 PM

    Thao – thx. I can’t think of any reason why that would be a bad idea…but – I would go back and re-read to make sure that the number doesn’t need to be “unique” per URL. Something sticks in my head that it does, for both google news and permalinks. If you use the same number on all pages, only the postname is unique.

  • Thao/ 15 Jun 11 @ 9:02 PM

    A quick Google search located the “Technical Requirements” set by Google to be included in Google News – http://www.google.com/support/news_pub/bin/answer.py?answer=68323&cbid=1d7kv7l9u7to0&src=cb&lev=answer

    It is Rule #3 that relates to the numerical requirements. It in-part reads this …. “Display a three-digit number: The URL for each article must contain a unique number consisting of at least three digits”. It goes on to states this little nugget on info … “if the only number in the article consists of an isolated four-digit number that starts with 199 or 200, we won’t be able to crawl it”.

    My interpretation of that rule means most of the WP Permalink Options won’t meet the Google News Index requirements? I must be interpreting it wrong, surely?

    - Default: /?p=123 (Won’t meet the requirement for the first 99 posts. Also, post ID numbers 1990 though to 2009 (which are ID’s not dates!) are “isolated four-digit number that starts with 199 or 200″ and therefore Google “won’t be able to crawl it”. And if they update “200″ to “201″ that rules out post ID numbers 1990-2020).

    - Day and Name: /2011/06/16/sample-post/ (What happens if/when you publish >1 post on any day? All posts for each day have exactly the same non-unique numerics)

    - Month and Name: /2011/06/sample-post/ (Again, every post for each individual month will have non-unique numerics)

    - Numeric: /archives/123 (Won’t meet the requirement for the first 99 posts. Post ID’s 1990- 2009 are “an isolated four-digit number that starts with 199 or 200″)

    - Custom: (are these the only permalinks that can fit Google News criteria?)

    * Please note that Rule #3 is waived if you have Google News sitemaps

  • admin/ 15 Jun 11 @ 9:36 PM

    wow, that’s insane. I guess once you get enough ID’s %post_id% is just fine, but if you’re just starting out, the first so many might not work very well. Good thing is, comments, pages, tags, and categories all increment the ID count, so you don’t have to wait until you get 200 posts, the count goes up a lot faster than you think.

  • How to Create Custom Post Types in WordPress « JTPRATT Wordpress Consultant/ 16 Jun 11 @ 1:36 AM

    [...] WordPress Permalinks for SEO and Speed [...]

  • Otto/ 16 Jun 11 @ 6:24 AM

    Bottom line it:

    If you have continually posted new content, in a sort of blog format, and where date is relevant information to the user, then use “/%year%/%postname%” and all your issues will be solved.

    If you also need to post content that you update directly, to keep current, or just want to put things in a URL structure of your choosing, then use Pages. They’re perfect for “static” content at a fixed URL.

    If you want to create various sections for different types of content, use custom post types and/or custom taxonomies for them.

  • Otto/ 16 Jun 11 @ 6:28 AM

    BTW, if you need to get into Google News, then do the following.

    1. Jump up your post IDs to at least 300. This can be done manually by simply creating a post and then manually editing the database to give it a post ID of 300 or higher. Later posts will then be above it.

    2. Use the permalink structure of /%post_id%/%postname%. This is acceptable to Google News as the post_id will be a unique number, and Google will ignore the number and use the postname as your keyword juice. Perfecto.

  • admin/ 16 Jun 11 @ 11:22 AM

    Thanks Otto, I really appreciate you stopping by!

  • admin/ 16 Jun 11 @ 11:23 AM

    perfect, this is good news! I know there are people out there that want to be indexed in Google News that like Thao were perplexed as how to do it. Thanks again for the VERY helpful comments!

  • Thao/ 17 Jun 11 @ 10:37 PM

    Yes thanks for the clarification Otto. I will have to learn how to manually adjust the post ID number via the database. It’s sounds like a very handy trick.

  • Babs/ 10 Jul 11 @ 2:08 AM

    Essential reading, JT, including the comments – thank you. As we add more to our WordPress sites, we have to keep it lean where we can.
    Your advice above will help that – now to go revisit a dozen to see what they are set to…

  • Shaun Baird/ 10 Oct 11 @ 10:12 PM

    HI, have read this with interest, but then saw your own site does not adhere to this – have you any newer thoughts on this, how ome you are not following a numerical permalink structure any more? thanks – confused!)

  • admin/ 11 Oct 11 @ 6:03 AM

    we never were, this blog has been online 6+ years now and has thousands of indexed pages. Also – it’s heavily cached.

  • Mircearcea/ 13 Feb 12 @ 2:19 AM

    I knew how to make my links look “pretty” but I didn’t know about the technical details on how wordpress assigns the page’s IDs.
    It’s definitely important to optimize your links but many people forget about the speed benefits they get if they have a site with thousands of articles.

Leave a Reply