How To Set Up and Rewrite Custom Permalinks in WordPress
Introduction
Permalinks are the URLs of pages and individual posts published on your WordPress websites. Name Permalink is short for “Permanent Link” – meaning these links can always be used to access your pieces of content. We’ll take you through the process oc creating a custom WordPress permalink.
WordPress permalink by default has the URL structure https://yourwebsite.com/?p=123.
This default permalink structure is bad because it offers no clue about the post. The user only gets to know what the post is about by clicking on the link. As a result, users may be less inclined to visit the page, and search engines less inclined to rank it.
If you’re launching a new WordPress site, you’ll need to change your permalink structure the user and an SEO friendly way. Also, if you have an established WordPress site, and you want to set its permalinks, then this tutorial is for you. In this guide to WordPress permalinks, we’ll show you the right way to go about it.
In this article:
- What is a Permalink in WP?
- Importance of Good Permalinks
- Considerations Before Setting Your Permalinks
- How to Set Pretty WordPress Permalink (Recommended)
- How To Setup Custom WordPress Permalinks
- Editing Permalink for Posts and Pages
- What is 301 Redirect?
What are WordPress Permalinks?
Permalinks are web addresses to blog posts and pages. WordPress provides web addresses for every post or page that you create. They are permanent assets and are not expected to change. However, you can customize the permalink structure if the need arises.
Permalinks consist of your domain name and the link slug. For example, in the link https://yoursite.com/woocommerce/how-to-install-woocommerce, “https://yoursite.com” is your domain, while “/woocommerce/how-to-install-woocommerce” is the slug.
WordPress has different options to choose from.
- Ugly permalink: WordPress creates a default permalink structure that contains numbers called the ID. This post ids are unique and identify every post or page you create. For example, https://yoursite.com/?p=99. This type is the default on all WordPress sites. Then again, this type of permalink setting is vague and is not good.
- Pretty permalink: These are SEO friendly URLs. They contain words that refer to the post or page. They look like this https://yoursite.com/name-of-post.
This WP permalink structure requires mod_rewrite module in Apache (or a similar module in other web servers).
- Almost pretty permalink: Similar to the pretty permalinks. Almost pretty one usually has the index.php prefix. For example, the link above would be https://yoursite.com/index.php/name-of-post.
This permalink structure can work without the mod-rewrite module.
Importance of Good Permalinks in WordPress
Permalinks in WordPress help users identify each content on your site. If it contains relevant words, users and search engines will have more information about the page. For example, “http://yoursite.com/attractive-and-charismatic-lady“ gives a hint on what to expect. Also, search engines use the context of permalink to rank content for search queries.
When you share good permalinks, you position your site to get more traffic. Human visitors are confident about clicking links that contain context to a post.
Considerations Before Setting Your Permalinks
You may want to avoid extremely long permalinks, and obscure ones as well. WordPress allows for a combination of structure tags in the URL structure, such as dates in your permalinks, ‘author’, ‘category’ etc. These combinations can result in long permalinks.
Obscure permalinks are URLs that contain few recognizable words. Using obscure links could be intimidating, confusing, and unfriendly.
Another thing to consider is the use of numbers only, on your URL. It does not give any clue about the post and is not good for search engines either.
We’ve put together a list of other things to consider before setting your permalink.
- Always use post names on your permalink. A post name on it makes it simple and easy to memorize. It is good for humans and search engines.
- Depending on the type of site you have, date tags in your site URL may be a great idea. For example, if you have a news website, it helps to categorize news by time. However, it may not be suitable for other types of sites. Information on any blog post that carries an old timestamp is perceived as old. Very few people will click on the search results that contain a date from years ago, even if the information is still relevant and correct.
- Categories enable you to organize your site content. If you have a site with multiple, distinct categories, displaying them in your permalinks make it easy to identify content from the URL. But it makes your permalink longer.
How to Set Pretty WordPress Permalink (Recommended)
We will now show you how to set up the pretty WP permalink structure.
Go to your WordPress admin area, and then go to Settings>>Permalinks.
Next, choose the “Post name” option. You may choose any other option listed on the page, depending on what your site is all about.
Then click Save Changes.
Your WP permalink is set.
Now you want to test to see if enabling pretty permalinks work.
To do this, create a new post on your site, enter a topic, and save it as a draft. When done, look at the permalink created. It should look like this https://yourdomain.com/name-of-post.
How To Setup Custom WordPress Permalinks
You may decide to specify a custom structure. This enables you to choose the tags you want to add to the URL of your pages and posts.
For example, you may want every link to contain the author name, category, and post name (such as https://yoursite.com/michael/woocommerce/how-to-install-woocommerce-payment-gateways).
To do this, login to your Dashboard and go to Settings>Permalinks.
Now select your desired structure tags (in this case %author%, %category%, and %postname%), and then Save Changes.
This custom WP permalink structure will now be used for all posts and pages on your WordPress site.
Editing Permalink for Posts and Pages
Sometimes, you may want to post slugs differently for some posts on your site, something other than the default WordPress slug. We will show you how to do this.
Method One
If you use the post name structure, you can easily edit the WordPress generated URL slug. It is usually the title of the post.
On the admin area of your site, navigate to Posts >All Posts>select an existing post. Click on the permalink text box to edit the WordPress generated slug.
Customize the slug by editing it as you wish. You may want to include SEO keywords in the URL. This can also be done in the Yoast SEO section if you have this plugin installed.
Click Update to save the changes.
If you are working on a new post, you can quickly edit the generated slug before publishing your post.
Method Two
Another way of creating WordPress custom permalinks on some posts is through the use of Permalink Manager Plugin. This plugin is lightweight and it enables you to change the slug and even the custom permalink structure.
To show you how this permalink plugin works, let’s assume that your site’s permalink structure is the Custom WP structure, and the year, month, day, and author tags are added to the post name tag.
To edit permalink on a post, select a previously published post.
Click on the Permalink Manager button under the title of the post. A textbox showing the post’s URL will be displayed.
Edit the URL as you wish. In this case, we removed the year, month, date, and author tags. We kept only the relevant keywords.
Click Update to save these changes.
And that’s it, the permalink for this post has been customized.
What is 301 Redirect?
When you change WordPress permalink of a page or post, search engine rankings would change. Search engines and other websites linking to that page will no longer be able to find it and this will lead to a drop in traffic.
To fix this, you need to set up 301 redirects. Redirects essentially redirect people who try to access your old URL to the new URL.
You can set up redirection using WordPress plugins and htaccess files. Redirection is one great, free plugin for this purpose.
Redirection plugin permits you to line up redirects. It also helps you find 404 errors (broken link), and redirect these on your WordPress site.
First, you should install WordPress plugin and activate it.
Next, go to Tools>>Redirection>>Start setup
The basic setup page will appear on the screen. Check all the applicable options and Continue setup.
At this point, the plugin checks the site for at least one working REST API. If there is, it will indicate Good.
Next, Finish Setup.
After setup completes, click on Finished.
Redirection is now active on your site.
To create actual permanent redirects, click Add New.
- Enter into the “Source URL” textbox the site’s URL you want to redirect from.
- Type in the target URL you want to redirect to.
- Click Add Redirect.
Conclusion
Unless you require some other format, we recommend the post name permalink structure.
If you were using the default permalink structure and you decide to change, please ensure you take care of redirects.
If you are creating a new site, you should not have to worry about redirect rules, simply set the WordPress permalink structure you prefer and you should be good to go.
More Resources:
- How To Easily Clean Up Your WordPress Database
- The Fastest WordPress Themes Of 2019
- WordPress Meta Description