Home Blog WordPress Management WordPress permalinks 101: The complete guide

WordPress permalinks complete guide

WordPress permalinks 101: The complete guide

Permalinks play a big role in WordPress. Not only do they allow us and website visitors to find pages and posts, but they also play a role in the general UX (User eXperience) of those who visit your WordPress site. Search engines also use permalinks to index your WordPress website.

Permalinks come in different shapes and sizes, making them a topic worth investigating. By understanding the different types of permalinks and their attributes, you will be able to choose the permalink structure that best works for you and your WordPress sites.

In this article, we will take a look at permalinks in WordPress; how they work, and what function they serve. We will also take a look at the permalink settings you need to know about so that you’re in a better position to make the most out of them.

To understand what WordPress permalinks are, we first need to look at URLs and their relationship to website structure.

Before the era of WordPress, websites used static files to display pages and posts. A website subdirectory required a corresponding folder on the web server, and a page required a corresponding HTML file saved on the web server. This meant the URL of a page reflected the folder and file structure on the web server.

Although there are still sites that use this setup, WordPress does not save pages and posts as files but as entries in the WordPress database. Database entries use IDs instead of paths to locate a particular file or page. Because of this, the default URL of a WordPress post looks like this:

Let’s break this down

  • https://melapress.com is the domain name
  • ? is a separator that makes a distinction between the domain name and the query string
  • p is a public query variable, which tells WordPress we are looking for a post
  • 122 is the query value, which, in this case, tells WordPress we are looking for a post with ID 122

This URL is also known as a permalink because it provides a permanent link to a resource (in this case, post 122).

Since we are dealing with a database, we can have a lot of fun with WordPress permalinks. Each query string can include multiple parameters, giving us the opportunity to present very specific results.

Let’s look at the following permalink structure:

https://melapress.com/?author_name=joel&category_name=WordPressSecurity&m=202401

This permalink will give us all of the posts that Joel wrote in January 2024 that have been categorized as WordPress Security. Here, you’ll notice the addition of ampersands (&), which effectively allows us to concatenate multiple queries into one query.

As I stated earlier, fun!

In the previous example we used the query variable ‘q’ to ask WordPress for post 122. WordPress, however, has a rather long list of query variables we can use. These variables can be either public or private.

Public queries can be used in public requests (within URLs), while private variables can only be used internally in PHP queries.

You can find WordPress permalinks documentation on WordPress.org’s website.

Permalinks, slugs, and URLs may seem to refer to the same thing; however, there are subtle differences between each one that are worth knowing. Understanding these differences, as nuanced as they might be, will help you ensure you take full advantage of everything permalinks have to offer.

  • Permalinks: Refers to the permanent link to a resource, such as a page or a post
  • Slug: Refers to the section of the permalink that is specific to that resource
  • URL: Often the same as the permalink; however, you can have a URL that is different than the permalink, as may be the case with redirection

Since all pages are stored in the database, WordPress must use queries to find the content of the page it needs to load. However, it can hide the query through the WP_Rewrite class.

The purpose of this class, which works in the background in a totally transparent manner, is to rewrite pretty permalinks into ugly permalinks.

We cover pretty and ugly permalinks in more detail in this section.

Since WordPress fetches pages from the database, it needs the query string in the ugly permalink to find the content.

WordPress automatically sets the permalink for you whenever you create a new page or post. While this can be edited before publishing, it can be very helpful to have it all set up and ready to go.

WordPress permalinks come in different flavors. These permalink structures determine how permalinks are set up whenever you create a new page or post. Of course, you can always enter your own custom permalinks. However, having a default WordPress permalink structure in place will help you be more efficient.

To set your permalink structure, first log in to your WordPress dashboard, then navigate to Settings > Permalinks. Here, you’ll find all the WordPress permalink settings for your site.

It’s important to note that when you choose a pretty permalink option in the WordPress dashboard, WordPress will automatically populate the custom permalinks field with the tags that make up that pretty permalink.

The screenshot below shows how WordPress automatically generates the corresponding tags in the Custom Structure field upon selecting the Post name option.

This provides us with the opportunity to edit any of the existing permalinks if we’re unhappy with any of the included tags.

Plain

Plain permalinks are the default options WordPress comes with. It is also referred to as the Ugly Permalink setting (rude!). It uses the p=N format, where p represents the parameter, and N is the unique number identifier. An example of a plain permalink is:

https://melapress.com/?p=122

Day and name

The ‘Day and name’ permalink option, also known as the Pretty Permalinks, combines the day (year, month, and day) and the post name in the following format: /%year%/%monthnum%/%day%/%postname%/.

https://melapress.com/2024/05/31/wordpress-security

Month and name

The Month and name option follows the previously discussed Day and name. However, it does away with the date combining month (year and month number) and the post name in the following format:

/%year%/%monthnum%/%postname%/

https://melapress.com/2024/05/wordpress-security

Numeric

The numeric option uses the same post ID you’ll find in the plain option, however hides the query variable. Using the example mentioned in Plain, the URL would look as follows:

https://melapres.com/archives/123

Note: /archives/ is automatically added by WordPress. To remove this option, simply scroll down to Custom Structure, select this option, remove the /archive/ part of the permalink, and save the changes made.

Post name

Post name is the most useful permalink structure available, taking the sanitized version of the post’s name. Here, spaces are replaced with a dash, so that a post with the title WordPress security will take the following format:

https://melapress.com/wordpress-security

Custom structure

Custom structure lets you define your own custom permalinks structure using any of the available tags. As previously discussed, this option is also populated automatically when choosing any of the pretty permalink options.

A number of permalink structures use prefixes and tags in the URL structure. WordPress has a Category base and a Tag base while 3rd party plugins such as WooCommerce may have their own.

In the Optional section of the Permalink Settings, we can choose a custom structure to replace the default values. For example, if we were to enter theme in the Category base field, any permalinks that used category in the URL structure, such as

https://melapress.com/category/security/

will be changed to

https://melapress.com/theme/security/

If you’re running WooCommerce on your WordPress site, you’ll also find a section dedicated to WooCommerce product permalinks in the WordPress permalinks settings section. Here, you can choose one of the default structures or a custom structure that you can configure yourself.

  • Default: Uses the default WooCommerce permalink structure as follows, /product/sample-product/
  • Shop base: Uses the shop-based WooCommerce permalink structure as follows, /shop/sample-product/
  • Shop base with category: Uses the shop and category-based WooCommerce permalink structure as follows, /shop/product-category/sample-product/
  • Custom base: Enables you to enter to configure your own custom permalinks structure

Permalinks do more than look pretty or ugly. The right permalink structure can help you boost the SEO and visitor retention of your WordPress site, making it a low-hanging fruit that is definitely worth picking.

The right permalink URL structure can help you improve:

Navigation

Permalinks are used to locate and navigate pages across your website. If you want to share content on social media or on another website, you’ll do this through the permalink. As such, having a permalink that potential visitors can make sense of can help increase your click-through rate.

SEO

Search engines use the set permalinks to index content, making permalinks that are SEO-friendly a no-brainer. Using keywords in the permalink will help search engines like Google understand what your page is about.

UX

Everyone likes pretty, and pretty permalinks make the user experience more enjoyable. It helps visitors better understand how to navigate your website and remember important pages. Let’s face it: it is easier to remember the permalink https://melapress.com/support/ than it is to remember https://melapress.com/?p=558/

Trust

One thing that is often overlooked when it comes to setting the permalink structure is trust. Website visitors are more likely to trust links that they can read and make sense of. A link with seemingly random numbers can make users suspicious, which ultimately drives users away.

WordPress permalink settings offer a wide range of options to accommodate the requirements of your WordPress site. Whether you’re configuring permalink settings for a new website or updating the WordPress permalink structure of an existing website, there are some things you’ll do well to keep in mind:

Search engine optimization

Search engines use permalinks to index the content of your website and understand what it is about. Useful permalinks can help you improve your SEO efforts, however they need to fit within your overall SEO strategy.

For example, if we want to publish an article about permalinks on WordPress, a good slug would be wordpress-permalinks, which, in our case, would give us the permalink:

https://melapress.com/wordpress-permalinks

On the other hand, if the article centered around permalinks for WordPress marketing specifically, an SEO-optimized permalink would read:

https://melapress.com/wordpress-marketing-permalinks

The two most important things here are:

1: Keeping the permalink as short as possible

2: Keeping the permalink as closely related to the main keyword as possible

Growth

As your website grows, so will your content. Pick a WordPress permalink structure that accommodates growth. The last thing you’ll want is to have to change the permalink URL structure frequently.

Think about how your website might grow, whether it’s products or services you sell, topics you cover in your blog, or any additional content you might want to serve on your website. Then ensure the new permalink structure is able to accommodate such expansions. While it might seem like unnecessary work, your future self will definitely thank you for it.

To illustrate this with an example, let’s imagine an e-commerce website owner who is looking to change the permalink structure of their website. We’ll call him Steve.

Steve currently sells t-shirts in different colors and, as such, is planning on using product color as the product category base. However, Steve should account for the possibility that his business might expand to sell pants in the future. Instead of choosing product color as the Product category base, he should choose product category so that the new permalink structure will accommodate future expansion into pants and other clothing items.

Before changing the permalink structure of your WordPress site, there are a few things that you will need to consider. This is extra important if you’re changing the permalink structure of a live website that may already have inbound and internal links.

Excessive use of redirects is best avoided. Collate a list of links to your pages and if possible, reach out to owners of links from external sources to update the URL they are linking to.

If this is not possible, make sure you set up proper redirections to avoid 404 errors.

If you’re switching from Plain to another structure of permanent URLs, there is no need to set up any redirections since WordPress understands the Plain query. However, if you’re changing from any other type, you may need to update links or set up redirections. This will help you ensure all permalinks in WordPress continue to function as intended and take the visitor to where they want to go.

You can easily choose your preferred permalink structure right from the WordPress admin dashboard. First, log in and then navigate to Settings > Permalinks, where you’ll find all available options for setting your permalink structure within the Common Settings section.

We have covered the different options available in the Available permalink options section, so be sure to scroll up if you want to get a better idea of what the available options mean.

You may also change the permalinks structure using phpMyAdmin. While this may be a slightly more complex way to update WordPress permalinks, knowing the procedure can prove to be a lifesaver should you ever find yourself in a tight spot.

  • First, log in to your WordPress’ phpMyAdmin.
  • Next, select the WordPress database and then select the wp_options table.

Here, you will need to look for permalink_structure in the option_name column and then click on Edit.

Enter the tag or tags you would like to use in the option_value field. Once ready, click on Go to update the values.

If you do not have phpMyAdmin, you can change the WordPress permalinks structure directly through the MySQL command line. Here, you’ll just as easily be able to set your own custom permalinks structure.

Log into MySQL and select the WordPress database by running the following command;

USE database_name;

Where database_name is the name of your WordPress database.

Now, we can go ahead and update the permalink settings by running the following query;

UPDATE wp_options
SET option_value = '/%tag%/' WHERE option_name = 'permalink_structure';

replacing /%tag%/ with the permalink structure you want to use.

WordPress permalinks can also be updated through WP-CLI, which offers command-line access to WordPress. The advantage here is that we can update the permalink settings without having to log in to the WordPress dashboard.

We’ll use the wp rewrite structure command to change our WordPress permalinks structure.

Log in to WP-CLI using SSH or your hosting provider’s backend.

Once logged in, type the following command, replacing tag with the permalink structure you want to use:

wp rewrite structure '/%tag%/'

and press Enter. WP-CLI will then rewrite the structure set and flush the rules.

Permalinks play a critical role in any WordPress website. Changing permalinks without accounting for inbound and internal links can hinder search engines and visitors from finding pages on your website, resulting in 404 errors. 

404 errors can cause you to permanently lose important inbound links, affect your SEO, and degrade the user experience. Not good. 

Keep an eye on 404 errors and set up 301 redirects when and where required to ensure existing links are redirected to the correct page..

Frequently Asked Questions

What are WordPress Permalinks?

WordPress permalinks are links to WordPress pages. For example, a blog post can have the following permalink: www.mywebsite.com/blog/my-blog-post. In this case, we are using the post name as the permalink to the post.

WordPress allows us to use different permalink structures using tags, which allow for a high degree of customization. Permalink settings, can be configured by navigating to Settings > Permalinks. Here you can also set custom permalinks should you wish.

How to set Permalinks in WordPress?

The easiest way to set WordPress permalinks is through the dashboard. Navigate to Settings > Permalinks and choose the option that best fits your requirements. You can also set permalinks through phpMyAdmin and WP-CLI.

What is the difference between a URL and a permalink?

Permalinks are direct, permanent links to a resource such as a blog post and can be configured in the permalink settings page in your WordPress dashboard. URLs, like permalinks, are links to resources, however they do not have to be direct or permanent. A URL can be redirected while a permalink always point to a specific pag

Posted inWordPress Management
Joel Farrugia
Joel Barbara

Joel is our technical writer responsible for writing the different kinds of content we need. With a background in tech and content, he has a passion for making technology accessible and understandable for everyone. You can reach Joel at joel@melapress.com.


Leave a Reply

Your email address will not be published. Required fields are marked *

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon
Uploading WP 2FA as a zip file in WordPress
WP 2FA in the WordPress plugin repository
Close

Installing WP 2FA Free

Congratulations on taking the first step towards enhancing your WordPress site's security with WP 2FA Free! You're now on your way to protecting your valuable data and ensuring peace of mind. No coding or technical knowledge is required.

 

Below are two ways to install WP 2FA on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for WP 2FA.

Download the WP 2FA plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading CAPTCHA 4WP as a zip file in WordPress
CAPTCHA 4WP in the WordPress plugin repository
Close

Installing CAPTCHA 4WP Free

Well done you. You're one step closer to safeguarding your WordPress website from spam and automated attacks with CAPTCHA 4WP. You'll be able to effortlessly integrate CAPTCHA into your forms and enjoy a website with enhanced security.

 

Below are two ways to install CAPTCHA 4WP on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for CAPTCHA 4WP.

Download the CAPTCHA 4WP plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading WP Activity Log as a zip file in WordPress
WP Activity Log in the WordPress plugin repository
Close

Installing WP Activity Log Free on your website

You deserve a pat on the back for choosing to record user actions and changes on your website. That is the first step towards better user accountability, easier troubleshooting of website security, and many other benefits of issues.

 

Below are the two ways to install WP Activity Log on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for WP Activity Log.

Download the WP Activity Log plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading Melapress Login Security as a zip file in WordPress
Melapress Login Security in the WordPress plugin repository
Close

Installing Melapress Login Security Free

Congratulations on taking control of your WordPress website's security by implementing robust login and password policies with Melapress Login Security. You can change your login page URL, limit failed login attempts, and reset passwords.

 

Below are two ways to install Melapress Login Security on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for Melapress Login Security.

Download the Melapress Login Security plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2