WordPress Permalinks

How To Set Up and Rewrite Custom Permalinks in WordPress

WordPress Permalinks

Introduction

Permalinks are the urls of pages and posts published on your WordPress site. Permalink is short for “Permanent Link” – meaning these links can always be used to access your content. In some cases, permalinks do not have any suitable context for it. As a result, users may be less inclined to visit the page, and search engines less inclined to rank it.

WordPress permalink by default has the structure https://yourwebsite.com/?p=123.

This 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.

If you’re launching a new WordPress site, you’ll need to set your WordPress permalink the user and SEO friendly way. Also, if you have an established WordPress site, and you want to set its permalinks, then this tutorial is for you. We’ll show you the right way to go about it.

In this article:

What are WordPress Permalinks?

Permalinks are web addresses to blog posts and pages. WordPress creates web addresses for every post or page that you create. They are permanent assets and are not expected to change. However, you can make edits 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 permalink options to choose from.

  1. Ugly permalink: WordPress creates a plain permalink that contains numbers called the ID . This number is unique and identifies every post or page you create. For example, https://yoursite.com/?p=99. This type of permalink is default on all WordPress sites. Then again, this type of permalink is vague and is not good.
  1. Pretty permalink: These are search engine friendly URLs. They contain words that refer to the post or page. They look like this https://yoursite.com/name-of-post.

This permalink structure requires mod_rewrite module in Apache (or a similar module in other web servers).

  1. Almost pretty permalink: Similar to the pretty permalinks. Almost pretty permalink usually have 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.

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. 

You may want to avoid extremely long permalinks, and obscure ones as well. WordPress allows for a combination of tags in the URL structure. Such as ‘year’, ‘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 postname on your permalink 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.

 

We will now show you how to set up the pretty 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.

Postname option in Settings

Then click Save Changes.

Click on save changes button

Your WordPress permalink is set.

Now you want to test to see if this structure works properly.

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 “https://yourdomain.com/name-of-post.

Changing Post Permalink

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 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 choose your desired structure tags (in this case %author%, %category%, and %postname%), and then Save Changes.

Custom Permalink Structure

This custom permalink structure will now be used for all posts and pages on your WordPress site. 

Sometimes, you may want to use a different slug 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 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.

Editing Post Permalink

Customize the slug by editing it as you wish.You may want to include SEO keywords in the url.

Click Update to save the changes.

Adding SEO keywords in Slug

 

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 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 permalink structure.

To show you how this plugin works, let’s assume that your site’s permalink structure is the Custom structure. And the year, month, day, and author tags are added to the post name tag.

Setting up the custom structure url

 

To edit permalink on a post,select a previously published post.

Selecting previously published post for editing

Click on the Permalink Manager button under the title of the post. A textbox showing the post’s url will be displayed. 

Permalink Manager plugin section

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.

Click Update to save plugin changes

And that’s it, the permalink for this post has been customized. 

 

What is 301 Redirect?

When you edit the permalink of a page or post, search engines and other websites linking to that page will no longer be able to find it. This will lead to a drop in traffic.

To fix this, you need to setup 301 redirects. Redirects essentially redirect people who try to access your old url to the new url.

You can setup redirection using plugins and Redirection is one great, free plugin for this purpose. 

Redirection plugin permits you to line up redirects. It also helps you find 404 errors, and redirect these on your WordPress site.

First, install and activate this plugin.

Next, go to Tools>>Redirection>>Start setup

Activating Redirection PluginRedirection plugin Start Setup button

Basic setup page will appear on the screen. Check all the applicable options and Continue setup.

Check options and click on Continue setup button

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. 

Click on Finish setup button

After setup completes, click on Finished.

Finishing the redirection

Redirection is now active on your site.

 

To create actual permanent redirects, click Add New.

  1. Enter into the “Source URL” textbox the site’s url you want to redirect from.
  2. Type in the target url you want to redirect to.
  3. Click Add Redirect.

Adding a new redirect

Conclusion

Unless you require some other format, we recommend the postname permalink structure. 

If you were using the default WordPress 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 redirects, simply set the permalink structure you prefer and you should be good to go.