Best WordPress Permalink Structure – The Definitive Answer

There are millions of WordPress blogs on the internet and there are also many different opinions on which is the best WordPress permalink structure. If you search for “best wordpress permalink structure”, there millions of results and this article will also contribute to that collection!

So why should I write another article about WordPress permalinks? Hasn’t this been done to death? The short answer is that the majority of those “best wordpress permalinks” articles give bad advice which will make it very hard for you to change your permalink structure at a later date when you have hundreds or thousands of blog posts on your site.

Over the years I have setup quite a few WordPress installations with different permalink structures, but after doing all the research and finding what works best for me, I thought I had better share it with you… so you do not get your blog into a bad state that you cannot easily fix.

I will also show you how to change your permalink structure to the one I recommend without generating 404 File not Found errors for anyone linking to your posts.

What are WordPress Permalink Structures?

If you are reading this post, I assume that you already know what permalinks are, but I will give a short overview for those who are unsure.

So your readers can access your blog posts, WordPress needs to serve up those pages as unique URL’s. The way that the URL’s are displayed can be configured.

If you go into your WordPress Admin Panel and go to Settings -> Permalinks, you will be presented with the following page.

Here are the default suggestions from the page and the reasons why you should not use them:

  • Default – http://www.domain.com/?p=123
    This human unreadable format is useless for SEO purposes, but could be more efficient since it results in faster database lookups. Quite simply avoid this permalink structure since the efficiency gains do not help your SEO. You would be better off to move to a faster web server, rely on WordPress speed improvements as the core is updated or use caching plugins.
    Verdict: Do not use.
  • Day and Post Name – http://www.domain.com/2011/07/21/sample-post/
    This permalink structure is better since it displays the post name in human readable form, but it also puts the post date in the URL. There is no need to put the date in the URL since you would not expect your readers to manually enter or change the URL’s. Some people have told me that they like to manually alter the URL so they can see what posts were made in say 05/2010. But seriously, your users should be using the web interface to select posts. Next time you are in Gmail, have a look at the URL. It’s a GWT application, but I don’t think there is any benefit in trying to manually punch values into the URL yourself. You are bypassing the applications API and this will generally lead to unpredictable results.
    Verdict: Do not use.
  • Month and Post Name – http://www.domain.com/2011/07/sample-post/
    Same reasoning as above.
    Verdict: Do not use.
  • Numeric – http://www.domain.com/archives/123
    This is similar to the default permalink setting. Might be slightly more efficient, but results in poor SEO.
    Verdict: Do not use.

Here are some other common variations that I have seen:

  • Category and Post Name – http://www.domain.com/category/sample-post
    This one isn’t too bad since it is human readable and adequate for SEO. But there are a few reasons why I do not like it. The first reason is that by having the category in the URL means that you will not be able to rename or delete that category in the future (since other sites may have linked to that particular post). I like to keep my blogs organized and regularly move my posts into different categories, so this structure is not good for me. The second reason is that the keywords in the post name are pushed further away down the URL and hence the search engines will give less weighting to those keywords. It is simply best to have your keywords in the URL as close to the top level domain name as possible.
    Another variation of this permalink structure is to use the tag name which obviously has the same disadvantages.
    Verdict: Passable, but I would avoid it due to the reasons given above.
  • Only Post Name – http://www.domain.com/sample-post
    Right… we are now getting closer to the optimum permalink structure. This permalink structure has no dates, categories or tags, just the human readable post name which is located close to the top level domain. It’s just about perfect, but a little more research reveals the reason why it isn’t.
    According to the Codex page on Permalinks, only postname may cause you problems “If you use postname as the only element in your permalinks to create a structure such as example.com/post-title, the rewrite rules may make it impossible to access pages such as your stylesheet (which has a similar format) or the /wp-admin/ folder. It’s best to include some numeric data (e.g. the post ID or date) in the permalink to prevent this from happening.
    Verdict: Passable, but this permalink structure may mask other similarly named files on your web server.

And the Definitive Answer is…

  • Custom structure (Post Name and Post ID)
    http://www.domain.com/sample-post-123/
    This permalink structure is human readable, perfect for SEO, has the keywords close to the top level domain name and also contains a unique numeric identifier so it will not mask other files on your web server.
    Having the Post_ID in the URL is also handy when you are hacking away in the database or you need to find a post quickly on your site after viewing logs etc.
    Google News includes quite a few multi-author blogs in their index and one of their technical requirements says that all article URLs must contain a unique number. If in future, this blog grows and gets included into Google News, I won’t have to alter the permalink structure because there’s a unique number already in the URL – it’s called Post ID.
    The permalink setting to use is: /%postname%-%post_id%/
    Verdict: This is the one to use.

Does my Recommended Permalink Slow Down your Blog?

Previously (pre WordPress 3.0), my recommended permalink structure may have had slightly worse performance. But since WordPress 3.0, lots of changes have been made to the WordPress core, so this should no longer be an issue. But in any case you should do your own benchmark testing and make your own decision. You can always upgrade to a faster web server or use a CDN to boost your page load speeds. I run this permalink structure on WordPress sites with thousands of posts and have no issues. The SEO benefits far out-weight any slight loss in page load times.

How can you Change your Permalink Structure without Losing Page Rank?

You are probably in the situation that your blog has hundreds of articles that other sites have linked to. If you change your permalink settings, this will result in many 404 File not Found Errors and your site will definitely lose page rank.

I have been in this situation myself and there are a number of WordPress plugins that allow you to migrate from one permalink structure to another. Simple go to WordPress.org and search the plugin repository for “permalink”.

But there is one plugin that I have used in the past that is quite useful. As long as your original permalink structure had the post name somewhere in the URL, you can use the Smart 404 plugin.

The Smart 404 plugin stops your viewers from seeing site errors. When content cannot be found, Smart 404 will use the current URL to attempt to find matching content, and redirect to it automatically. Smart 404 also supplies template tags which provide a list of suggestions, for use on a 404.php template page if matching content can’t be immediately discovered.

I have successfully migrated sites from the “category-postname” and “postname” permalink structures to the permalink structure that I suggest without losing page rank or causing any other issues.

If you are setting up a new blog… then now is the time to get the permalink structure correct from day one.

One Last Note – Use Shortlinks for Internal Links

Now that you have setup your permalinks to use the structure I recommend, there is one last thing you need to be aware of. If you are linking to other pages in your blog, make sure to use the shortlink instead of the nice human readable URL.

You can determine the shortlink of any post by clicking the “Get Shortlink” button that appears when you are editting the post.

By using shortlinks, even if you do change your permalink structure at a later date, those internal links will still work ok.

29 Comments

  1. Hi Kirk,
    Firstly thanks for the insights regarding permalink structures. I was aware of the benefits of including the keywords in the permalink but I didn’t know that additionally including the post id has added benefits such as the prevention of masking. Looks like I’ll be changing the links on my site to include the post ID too.
    Thanks for the tip!

    • Hi Bob,
      Adding the Post ID can definitely save you from having some weird problems with filename masking. It’s not essential, but I like to add it because I can always easily get to the post (referenced in an analytics reports or link checkers etc) by just typing the Post ID.

  2. Good job Kirk! Explains everything nicely.

    • Thanks Amin. I just wanted to put together a short article with a decent recommendation so that everyone else doesn’t have to do the research.

    • Hi Jenni. Thanks for your comment, but saying that your permalinks shouldn’t start with the post name is not the best advice. Sure… it *may* be slightly faster by a few milliseconds, but SEO is far more important than the slight decrease in page load times. I run other WordPress installations with thousands of posts and the database lookup speed is not an issue with the permalink structure I recommend in this post. Moving to a faster web server or using a CDN will greatly speed up your page load times as well. Having the post name positioned first in your permalink structure gives you many SEO benefits.

      • Completely agreed with you now!

  3. Hello Kirk,

    Very good post and I can see the logic of using the structure. As you said most of the advise on the Internet is that you should use /%post_id%/%postname% permalink structure which, after reading your post, means that it is not the best option. I had a n00b question though what does ” it will not mask other files on your web server” mean? Can you please elaborate on that.

    Thanks in advance.

    Pali Madra

    • Hi Pali…. what I mean by “masking other files on your web server” is that if you make your permlinks “/%postname%”, then if you do something crazy like create a post that has a slug of “wp-admin” or “styles.css” then you might find that your post actually masks (or overrides) the real file on the web server. In the first example, you might not be able to login. Sounds very crazy, but it did happen to me once with very unpredictable results when I used just “/%postname”. Now I append the post ID and file masking can no longer occur. It’s a rare problem, but very frustrating when it happens!

  4. Sorry for the double comment. I apologize.

    The question I had was whether using category in the permalink structure is a good idea or not as the categories are usually related to the keywords for a post.

    Pali Madra

    • Sure… no problem. Ask away!
      Yes you are right, the category usually has some keywords that are beneficial for SEO purposes. BUT the main problem is that if you reorganise your posts into other categories then all the external links into your site will be broken. This will result in 404 file not found errors which is terrible for SEO when Google is crawling your site. The other problem is the “meat” of the URL (the post slug) is further away from the top level domain and hence will have less SEO impact. It’s best to get the post slug next to the top level domain and use a WP SEO plugin.
      I had a major site with permalinks set to “/%category%/%postname%” and everything was great UNTIL I decided to reorganise my categories which caused lots of broken links. The only thing that saved me was that Smart 404 plugin that I mentioned in the post. Now I run all my sites with the permalink structure I recommend “/%postname%-%post-id%”.

  5. Thanks for the post. The recommendation to use the Smart404 was a tremendous point. Glad you didn’t leave that out. I wouldn’t have thought about the repercussions of changing my permalinks had you not mentioned that bit.

    • Glad I could help you out. I think as long as you have the Post Name in your permalink structure, you can pretty much change to any other permalink structure rather easily.
      A bad situation is having the category or tag in the permalink structure. This limits how you can organise your posts at a later date.

  6. Helo Kirk. Great post with reasonable contradiction than most advice regarding WP permalinks. I never thought you will recommend that. :)

    I was thinking about using /category/postname/ structure and remove category base using a plugin available to do just that. On the surface that’s the most ideal structure for my new WP based site with more than 30 categories. BUT the potential performance issue makes me somewhat subsided. Also your emphasize on reorganization problem makes me more hesitate to go with that.

    My second option was /post_id/category/postname/ to get the best of both world (SEO vs performance). Now I have third option although I must remove category from it. But I do not mind as long as the benefits exceed the drawbacks.

    Do you have any second thought about my first two options (with category)? Considering big improvements for permalinks in the next WP release: http://wpdevel.wordpress.com/2011/07/27/wordpress-3-3-proposed-scope/

    Thanks

    • Hi Danny, thanks for your questions and here are my recommendations for you.
      1) I wouldn’t use the /category/postname/ permalink structure. I had a blog with this structure once, and it was a pain to reorganise the categories (I like to be organised). It’s not a problem if no-one has linked to your blog, but if they have, then you do not want to change your categories at all. A plugin will redirect in most cases, but it is not 100% perfect and there might be clashes. I don’t think it adds any value to have the category in the URL. Sure, it’s an additional keyword, but look at the URL for this post. Adding the category “wordpress” to this URL is redundant. I like making my URL’s descriptive… so the category does not have any value in general for me.
      2) Possibly better performance… but more pain for you since the category is once again in the URL. If you really want that… go with /post_id/postname/ instead. (I still prefer mine though).
      3) The guys at WordPress are always optimizing the core code, so performance issues shouldn’t be an issue. As time progresses, your web server will be upgraded etc. I prefer to focus on SEO first and only address performance issues if there is actually a problem. There is no use to optimize performance if you do not have a problem. For example… have a look at my Web Design Blog – http://www.blogwebdesigner.com – This blog has 2000+ posts and performance is quite ok with the permalink structure I recommend. So if I don’t see issues with 2000 posts, there is no use optimizing for performance if you only have 100 posts etc.
      Thanks for stopping by… and I hope that helps you decide. But try my recommended structure. It took me a year of trials to determine that it is the best one.

      • One more question. What about your last note about internal links. I mean wouldn’t it be better for SEO (I think you are more inclined to SEO side) if we use human readable URL than shortlink? Yes it would be a problem if we change URL structure later, but it’s the ONLY problem right? Wouldn’t the benefit outweighs the drawback if we use full URL?

        Thanks for your detailed thoughts.

        • Great question. The thing to remember is that Google indexes your site using the normal human readable URLs which will appear in search page results. Your internal links (using shortlinks) will also have appropriate anchor text. Google will not use the URL of the target page in the shortlink format, since it will be automatically permanently redirected to the human readable URL form. That’s why it doesn’t matter in this case. Try entering a shortlink URL into a browser for your website. See how it is automatically redirected to the correct URL?
          The reason why I like to use shortlinks for internal links is that if you ever change your permalink structure at a later date, everything will still work. In an ideal world, all external links to your WordPress site would be using shortlinks, and if that was the case, you could change your permalink structure whenever you wanted to with minimum problems and no SEO penalty.
          Another tip: If I put a screencast tutorial on YouTube etc, I always add to the YouTube description a shortlink to the actual article. Something like “Read the full article at: http://www.eblogcamp.com/?p=1648“.
          One final note. I always tell people to write good content and get some decent traffic before trying to optimize everything for a situation that might never occur. For example, recently I ran a few blogs on shared hosting (on a quality web host provider). Traffic was increasing and even after optimizing the hell out of everything, they kept on suspending my account for excessive server load. I then had to upgrade to a VPS… and the problem was solved. Maxing out your web server is a great problem to have. :)

  7. I definitely like your very last phrase. Yes, that’s absolutely true, you might have no internal problem when changing the structure of permalink.

  8. What I like about this post more than the advice is that you actually follow you advice. Most of these posts are on websites that simply use %postname% while telling you not to do it.

    Your “definitive answer” is helpful in that it address the Google News issue, but otherwise simply says SEO is more important than speed.

    From reading around (e.g. Otto on WordPress and others), the speed hit varies based on the number of pages you have and whether the pages are cached. This (and the relative importance of SEO for any given site) would seem to be how o make a decision.

    From most sites that address this issue, the speed issue must not be major because they simply use %postname% and screw Google News. Your answer because I don’t think there’s much downside to the numbers at the end and I suspect caching of 10-20 pages should be sufficient to limit any problems.

    • Hi DesignOdyssey,
      Thanks for your detailed comments. Glad you noticed that I actually use my own advice! I don’t think performance is too much of an issue with the latest versions of WordPress and it’s getting better all the time. So I optimize for SEO, use Smush.It on all images and remove all unnecessary plugins as well. You can also get a speed boost if you use quality web hosting (instead of the usual cheap overloaded web servers).
      Lately I have found the post_id at the end of the URL to be most helpful, especially when manually tweaking the database etc.
      Have a great day!

    • Hey Kirk, great post. I have always just used Postname in all my WP sites but I see now why post ID can help with effecting the rewrite rules. Is there any other reasons besides the rewrite rules and making it easier to find a post? Not that this isn’t enough reason just curious if there any other value to this.. Thanks.

      • Hi TJ, those are the main reasons for me and I find it handy. It’s probably not for everyone so just /%postname%/ should be ok if you don’t like having the Post ID in the URL.

        • Thanks Kirk. I’m going to take your advice and as the post id from here on out. Just did it for two sites today. And when posting on one of my sites I actually had to think if I posted the same article already so I can see where this can help with unique ids. Thanks again.

          • Ok great!

  9. Good tip! I think a lot of people leave it at the strange and ugly URLs that most of the CMSs create by default. Apparently, the claim is that this is better for SEO as well. I have been using /%category%/%postname%.html as my permalink structure for a while.

  10. How can you Change your Permalink Structure without Losing Page Rank?

    You can use “Permalink Finder Plugin”. It will automatically give 301 redirect to new URL.

  11. Thanks It will help me to select permalink structure for my blog.