url wordpress_如何从WordPress URL中删除日期

url wordpress

Do you want to remove the date from your WordPress URLs?

您是否要从WordPress URL中删除日期?

WordPress comes with an SEO friendly URL structure. This includes several link formats including one that adds dates to your WordPress post URLs.

WordPress带有SEO友好的URL结构。 这包括几种链接格式,其中一种将日期添加到WordPress帖子URL中。

In this article, we will show you how to easily remove the date from your WordPress URLs.

在本文中,我们将向您展示如何轻松地从WordPress URL中删除日期。

Removing date from your WordPress URLs
为什么日期显示在WordPress URL中? (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:

默认情况下,WordPress对帖子和页面URL使用非人类可读的链接结构,如下所示:

https://example.com/?p=123

https://example.com/?p=123

It uses post ID in the URL which does not look very good or meaningful.

它在URL中使用的帖子ID看起来不太好或没有意义。

However, WordPress also allows you to easily change this to more meaningful and SEO friendly URLs. It gives you a bunch of options to choose from under Settings » Permalinks page.

但是,WordPress还允许您轻松地将其更改为更有意义和SEO友好的URL 。 它为您提供了一系列设置>固定链接页面中的选项。

Permalinks page

Choosing the ‘Month and name’ or ‘Day and name’ options will add the date parameters to your WordPress URLs. They will then look like this:

选择“月份和名称”或“日期和名称”选项会将日期参数添加到您的WordPress URL中。 然后,它们将如下所示:

Day and name: https://example.com/2020/09/03/sample-post/
Month and name: https://example.com/2020/09/sample-post/

日期和名称:https://example.com/2020/09/03/sample-post/
月份和名称:https://example.com/2020/09/sample-post/

These URLs are better than the default ugly URLs. They are still SEO friendly as well. However, they are unnecessarily lengthy and the dates make your articles look old.

这些网址比默认的丑陋网址更好。 他们仍然对SEO友好。 但是,它们不必要地冗长,并且日期使您的文章显得陈旧。

That’s why a lot of users want to switch to just ‘Post name’ URL structure which will remove the date and just use the post slug keyword in the URL.

这就是为什么许多用户只想改用“帖子名称” URL结构来删除日期,而只在URL中使用post slug关键字的原因。

Name: https://example.com/sample-post/

名称:https://example.com/sample-post/

It is shorter, meaningful, SEO friendly, and doesn’t look dated as time passes.

它更短,更有意义,对SEO友好,并且随着时间的流逝看起来不会过时。

从WordPress URL删除日期之前应考虑的事项 (Things You Should Consider before Removing 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.

如果您正在启动一个新的WordPress博客并且尚未启动它,那么可以安全地从WordPress URL中删除日期。

However, if your website has been around for some time, then you will need to keep the following things in mind.

但是,如果您的网站已经存在了一段时间,那么您将需要牢记以下几点。

Changing the URL structure may result in 404 errors for your users and search engines. This means you may see warnings and errors in your Google Search Console reports.

更改URL结构可能为您的用户和搜索引擎导致404错误 。 这意味着您可能会在Google Search Console报告中看到警告和错误。

Your search engine rankings may also get affected as the link backs to your old articles will now lead to 404 errors.

您的搜索引擎排名也可能会受到影响,因为指向您的旧文章的链接现在将导致404错误。

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 the redirected URLs and will reset share count for them.

更改URL结构还将重置您的社交份额计数 。 不幸的是,大多数社交共享计数服务不会跟踪重定向的URL,而是会为其重置共享计数。

影片教学 (Video Tutorial)

演示地址

If you’d prefer written instructions, just keep reading.

如果您喜欢书面说明,请继续阅读。

从WordPress URL中删除日期 (Removing 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.

首先,您需要创建网站的完整WordPress备份 。 这样一来,您就可以将网站恢复到早期状态,以防万一您的网站无法正常运行。

After that, you need to visit the Settings » Permalinks page and choose ‘Name’ as your permalink option.

之后,您需要访问设置»永久链接页面,然后选择“名称”作为永久链接选项。

Change permalinks

Don’t forget to click on the ‘Save Changes’ button to store your changes.

不要忘记单击“保存更改”按钮来存储您的更改。

WordPress will now remove the date from your WordPress URLs and start using the name-based URL structure.

WordPress现在将从您的WordPress URL中删除日期,并开始使用基于名称的URL结构。

设置重定向以保留SEO排名 (Setting up Redirects to Preserve SEO Rankings)

Now that you have removed the date from your WordPress URLs. You need to set up proper redirects.

现在,您已从WordPress URL中删除了日期。 您需要设置适当的重定向。

Redirects will send users to the updated URLs without showing a 404 error. This will also help search engines understand that the old URLs are now moved to these new URLs.

重定向会将用户发送到更新的URL,而不会显示404错误。 这也将帮助搜索引擎了解旧的URL现在已移至这些新的URL。

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.

首先,您需要安装并激活重定向插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, you need to visit Tools » Redirection page and click on the ‘Start setup’ button.

激活后,您需要访问工具»重定向页面,然后单击“开始设置”按钮。

Start redirection setup

The plugin will then show you a couple of options. It can automatically detect and alert you if a posts URL is changed and keep a log of redirects. You can also leave both these options unchecked and simply click on the ‘Continue setup’ button.

然后,该插件将为您显示几个选项。 它可以自动检测并警告您帖子的URL是否更改,并保留重定向日志。 您也可以不选中这两个选项,只需单击“继续设置”按钮。

Continue setup

The plugin will then run some tests and if everything looks good then you can click on the Finish setup button. After that, it will store plugin settings into the WordPress database.

然后,该插件将运行一些测试,如果一切正常,则可以单击“完成设置”按钮。 之后,它将插件设置存储到WordPress数据库中。

Once finished, you will see the plugin’s settings page. From here, you need to click on the ‘Add New’ button at the top or scroll down to the ‘Add new redirection’ section.

完成后,您将看到插件的设置页面。 在这里,您需要单击顶部的“添加新”按钮或向下滚动到“添加新重定向”部分。

Add new redirect field

You will see a form with Source and Target fields. ‘Source’ is the field where you’ll describe your old URL structure and ‘Target’ is the location of the new URL.

您将看到一个带有“源”和“目标”字段的表单。 “源”是您将描述旧URL结构的字段,“目标”是新URL的位置。

If you were using the ‘Day and name’ URLs, then you will enter the following values in the source and target fields:

如果您使用的是“日期和名称” URL,则将在“源”和“目标”字段中输入以下值:

Source: /(\d*)/(\d*)/(\d*)/([A-Za-z0-9-*])Target: /$4

Redirect rules for day and name URLs

来源: /(\ d *)/(\ d *)/(\ d *)/([A-Za-z0-9- *]) 目标: / $ 4

If you were using ‘Month and name’ URLs, then you’ll enter the following values:

如果您使用的是“月份和名称” URL,则将输入以下值:

Source: /(\d*)/(\d*)/([A-Za-z0-9-*])Target: /$3

来源: /(\ d *)/(\ d *)/([[A-Za-z0-9- *]) 目标 :/ $ 3

Month name redirects

Don’t forget to select Regex and click on the ‘Add Redirect’ button to save your changes.

不要忘记选择正则表达式,然后单击“添加重定向”按钮以保存您的更改。

The plugin will now redirect users to your new name-based URLs.

现在,该插件会将用户重定向到您新的基于名称的URL。

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 collection of the best WordPress SEO plugins.

我们希望本文能帮助您学习如何轻松地从WordPress URL中删除日期。 您可能还想查看有关最常见的WordPress错误以及如何修复它们的指南,以及我们精选的最佳WordPress SEO插件

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.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-remove-the-date-from-wordpress-urls/

url wordpress

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值