How to Remove the Date From WordPress URLs
Do you want to remove the date from your WordPress URLs?
WordPress comes with an SEO-friendly URL structure. This includes several link formats, including one that adds dates to your WordPress post URLs.
In this article, we will show you how to easily remove the date from your WordPress URLs.
Why Dates Appear in WordPress URLs
By default, WordPress uses a non-human-readable link structure for post and page URLs, which looks like this:
https://example.com/?p=123
This uses the post ID in the URL, which doesn’t look good and isn’t very meaningful.
Luckily, the WordPress Settings » Permalinks page lets you easily change these default links to something more meaningful and SEO-friendly.
Some WordPress users choose the ‘Month and name’ or ‘Day and name’ options. These add date parameters to your WordPress URLs.
‘Day and name’ permalinks include the year, month, and day like this:
https://example.com/2023/09/03/sample-post/
‘Month and name’ permalinks include the year and month:
https://example.com/2023/09/sample-post/
These URLs are better than the default ugly URLs, and they are SEO-friendly as well. However, they are unnecessarily long, and in time, the dates will make your articles look old.
That’s why a lot of users prefer the ‘Post name’ URL structure instead. This removes the date and just uses the post slug keyword in the URL.
‘Post name’ permalinks don’t include any date information in the URL:
https://example.com/sample-post/
This URL structure is shorter, meaningful, SEO friendly, and won’t look dated.
Considerations Before Removing the Date From WordPress URLs
If you are starting a new WordPress blog and haven’t launched it yet, then it is safe to remove the date from WordPress URLs.
However, if your website has been around for some time, then there are a few things you should keep in mind.
Changing the URL structure may result in 404 errors for your users and search engines. This means you might see warnings and errors in your Google Search Console reports.
Plus, your search engine rankings may be affected since backlinks to your old articles will also now lead to 404 errors.
Both of these issues can be fixed by setting up redirects, and we will show you how to do that later in this article.
Changing the URL structure will also reset your social share counts. Unfortunately, most social share count services do not track redirected URLs and will reset the counts.
Removing the Date From WordPress URLs
First, you need to create a complete WordPress backup of your website. This will allow you to restore your website to an earlier stage in case things don’t work out as you expected.
After that, you need to visit the Settings » Permalinks page and choose ‘Post name’ as your permalink option.
Don’t forget to click on the ‘Save Changes’ button at the bottom of the page to store your changes.
WordPress will now remove the date from your WordPress URLs and only use the post name. It will do this both for your existing posts and pages and those you will add in the future.
Setting Up Redirects to Preserve SEO Rankings
Now that you have removed the date from your WordPress URLs, you will need to set up proper 301 redirects. As we said, this will stop your users from seeing 404 error messages when they follow an old link.
These redirects will send users to the updated URLs without showing a 404 error. This will also help search engines understand that the old URLs have been moved to the new URLs.
We will cover 2 methods you can use to create 301 redirects in WordPress:
Method 1: Setting Up Redirects Using AIOSEO (Recommended)
The best way to set up redirects is using the All in One SEO (AIOSEO) plugin. That’s because it includes a powerful Redirection Manager feature that lets you create bulk 301 redirects as well as automatic redirects, full site redirects, 404 error tracking, and more.
Note: You will need AIOSEO Pro to use the redirection manager. There is also a free version of AIOSEO, but it doesn’t include 301 redirects.
First, you need to install and configure the AIOSEO Pro plugin on your website. For more information, please refer to our step-by-step guide on how to set up All in One SEO correctly.
Once the plugin is active, you will need to go to All in One SEO » Redirects in your WordPress dashboard and then click the ‘Activate Redirects’ button.
You’ll now see the ‘Redirects’ tab in All in One SEO, where you can add your first redirect.
On this page, you will see settings where you can enter a ‘Source URL’ and ‘Target URL’.
The source URL will describe the old URL permalink structure, and the target URL will describe the new post URL permalink you need to redirect to.
To do this, we will use regular expressions, which are also known as Regex. Regular expressions provide a powerful and flexible way to search and manipulate specific patterns of characters. We will use them to match the permalink pattern in the URLs we need to redirect.
If you were previously using ‘Day and name’ permalinks, then you need to enter these Regex expressions into the source and target fields:
- Source URL:
^/(\d*)/(\d*)/(\d*)/([A-Za-z0-9-*])
- Target URL:
/$4
You will also need to click the cog icon next to the source URL to display three checkboxes. Make sure that only the ‘Regex’ box is checked. This option will enable regular expressions in the source and destination fields.
However, if you were using ‘Month and name’ permalinks, then you will need to enter these Regex values instead:
- Source URL:
^
/(\d*)/(\d*)/([A-Za-z0-9-*]) - Target URL:
/$3
Once you have added the source and target URL values, you should make sure that the Redirect Type is ‘301 Moved Permanently’ and then click the ‘Add Redirect’ button.
Your redirect will be created. Now, if a user clicks on a link that uses your old permalink structure, then they will be automatically redirected to the correct post using the new name-based URL.
You can see your redirect by scrolling down to the logs section. You can see how many website visitors have been redirected in the ‘Hits’ column, and you can enable or disable the redirect using the ‘Enabled’ toggle.
Method 2: Setting Up Redirects Using Redirection (Free)
You can choose our second method if you prefer to use a free plugin.
First, you need to install and activate the Redirection plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, you need to visit Tools » Redirection and click on the ‘Start Setup’ button.
The plugin will then show you a couple of options. It can automatically detect and alert you if a post’s URL is changed and keep a log of redirects.
You can also leave both these options unchecked and simply click the ‘Continue’ button.
The plugin will then run some tests, and if everything looks good, then you can click on the ‘Finish Setup’ button followed by the ‘Ready to begin!’ button. The plugin settings will be stored in the WordPress database.
You will now see the plugin’s settings page. From here, you need to click on the ‘Add New’ button at the top of the page or simply scroll down to the ‘Add new redirection’ section.
You will see a form with ‘Source URL’ and ‘Target URL’ fields. The source URL will describe the old URL structure, and the target URL will describe the new URLs.
If you were using the ‘Day and name’ permalinks, then you will enter the following values in the source and target fields:
- Source URL:
/(\d*)/(\d*)/(\d*)/([A-Za-z0-9-*])
- Target URL:
/$4
If you were using ‘Month and name’ permalinks, then you will enter the following values:
- Source URL:
/(\d*)/(\d*)/([A-Za-z0-9-*])
- Target URL:
/$3
Don’t forget to select ‘Regex’ from the drop-down menu before you click the ‘Add Redirect’ button to save your changes.
The plugin will now redirect users to your new name-based URLs.
We hope this article helped you learn how to easily remove the date from WordPress URLs. You may also want to see our guide on the most common WordPress errors and how to fix them, as well as our expert pick of the best WordPress SEO plugins.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید