Are you feeling stuck with your site’s current permalink structure? Are you terrified of changing it for fear of what Google might think? Fear not. This is a solvable problem. Let’s sort it out.
Setting up pretty permalinks is usually one of the first things that happens when a new WordPress website is set up. Hopefully, some forethought goes into picking the permalink structure. Realistically, the permalink structure on many sites is selected after a just a moment of reflection, and may not be the best structure for that particular site.
Once a site has been live for just a short time, changing the permalink structure can create some very real problems. Internal links can break, external links will start sending visitors to a 404 page rather than the intended content, and search engines will remove the pages whose permalinks have changed from their index. However, you can change permalink structure without causing all of these issues, as long as you do it right.
Why Would You Want to Change Permalink Structure?
Changing permalink structure is never ideal. No one picks a structure thinking to themselves: “I just can’t wait to change my mind six months from now.”
So, why might you need to make a change? Maybe the reasons why the original structure was selected have changed. Maybe you’ve decided to simplify the structure to improve readability. Maybe you’ve acquired a site and just hate the existing permalink structure. Or maybe you just didn’t give enough thought to permalink structure in the first place, and the structure has been wrong all along.
That last scenario is where I have found myself.
I run a small website called Intro to Pumps that I launched back in 2012. When I created it, I was just getting started with WordPress. Frankly, I had no idea what I was doing.
I did know enough to set up pretty permalinks. However, I didn’t know enough to pick the permalink structure that would best fit the content of the site. You can guess what happened as a result. I picked the wrong structure.
So here I am, four years after the fact, finally ready to fix what seemed like a very minor thing at the time, but it feels like a much bigger deal in retrospect.
Step 1: Settle on a New Permalink Structure
The first thing to do when considering switching permalink structure is to settle on a new structure. The WordPress Codex has a comprehensive and technical article on setting up permalinks, and we’ve covered the topic in the past as well.
You really have a lot of power over how permalinks are displayed. However, I’d recommend following a few guidelines:
- Only include publication date information if it’s relevant to your site.
- Get the post name in the permalink.
- Shorter permalinks are better since they’re easier to read.
When I created Intro to Pumps I opted for the Day and Name structure when I really should have gone with Post Name option instead.
You see, this isn’t a blog where content quickly grows outdated or where the date of publication matters. It’s an educational site that contains evergreen content. Adding dates to the permalinks just gives the impression that the information is going out of date. However, in the pump industry, change happens very slowly and this content will be relevant for a very long time.
In addition, the dates in the permalinks are just plain misleading. The earliest post on the site was published on November 11, 2012, and that date is reflected in the permalink. However, the content of the post was updated as recently as January of 2016. It bugs me to no end that the permalink makes it look like this is an old outdated post when I’ve been working hard to keep it up-to-date.
I’ve decided to change the permalink structure so that the dates are removed from post permalinks. However, if I just switch the structure and don’t set up 301 redirects, I’ll just create a bunch of broken links, the old URLs will be dropped by search engines, and the pages will be starting from scratch in terms of gaining SERP rank.
If you don’t want to use a plugin, you can also generate a custom page template that will display all post permalinks. Frankly, before finding the List URLs plugin, I had planned on implementing this method. However, List URLs worked so nicely I decided to skip the custom page template.
With a list of current permalinks in hand, it’s now time to update the permalink structure.
To do that, just go to Settings > Permalinks, select the preferred new structure, and click Save Changes.
Step 3: Set Up 301 Redirects
Now that you’ve changed the permalink structure, you need to create a 301 redirect from every old permalink to the new permalink.
There are many different ways to create 301 redirects. Any method you decide to use is fine, just make absolutely certain that you don’t miss any of the old permalinks when creating the redirects.
If you don’t create a 301 for each post, very bad things will happen:
- Any internal links that were created manually won’t be updated and will break.
- Any external links to the updated posts will send traffic to your 404 page rather than the appropriate post.
- The next time a search engine crawls those old URLs they will report back 404 errors and drop those pages from the SERPs.
Needless to say, properly setting up 301 redirection from the old permalinks to the new permalinks is the most important step in this process.
I used the Redirection plugin to create the redirect rules. It’s really easy to use and I just worked through the list I had created in the last step to make sure I didn’t miss any post URLs.
With the 301s set up, I did two things to test out the redirection rules:
- First, I manually typed in some of the old permalink URLs to make sure I was redirected properly to the new URLs.
- Second, I found some of the old URLs with a Google search and followed the links to make sure I was properly redirected to the new URLs.
Once you’ve verified that all of the old URLs are redirecting as intended you have a decision to make: How much does a fraction of a second mean to you?
Step 4: Fix Internal Links (Optional)
Any links that are generated by the WordPress core will be fixed automatically when the new permalink structure takes effect. This includes links generated by plugins in the sidebar, menu links (except custom menu links), and any links appearing in site search results and on archive pages. However, any links you created manually will still send visitors to the old URLs where they’ll be redirected to the new URLs.
This isn’t a huge problem.
If you set up the 301s correctly, visitors will end up on the right page. So fixing internal links isn’t strictly necessary. However, the redirection can add a fraction of second to your visitor’s page load time, and if every millisecond matters, you should take the time to find and fix any instances of your old permalinks.
There may be a really easy and safe way to identify and update every instance of an old permalink on a WordPress site. But if there is, I wasn’t able to find it. The fastest and simplest way I found to update internal links is to use Search & Replace or a similar plugin, to update the URLs directly in the database.
Be very careful when performing a search and replace operation on your website database. Always keep a recent backup, and move slowly. In addition, make sure that you only update links in the appropriate database tables. If you used the Redirection plugin I used, it creates database tables that hold the old and new URLs, and you don’t want to include those tables when you perform the search and replace operation or you’ll mess up the redirection rules you just created.
The best way to clean up your database is to clone your website to a local development environment first. Then, clean up the database locally, upload the cleaned-up database to a new database on your hosting account, and modify your site’s wp-config.php settings to point to the new database.
Wrapping it Up
Permalink structure has important SEO implications. Good permalinks are easy to read and relay useful information to site visitors and search engine web crawlers.
The best things to do is to give permalink structure careful forethought before setting up in the first place. However, if you mess up, you can still change the permalink structure. Just be sure to keep track of the affected URLs and set up the proper 301 redirects. If you don’t, site visitors and search engines may penalize your good intentions by skipping your content in favor of the competition.
View @ WPMU DEV