如何在WordPress中添加Hreflang标签

Do you want to add hreflang tags in your WordPress posts and pages? If you publish content in multiple languages or for different regions, then hreflang tag helps you improve SEO for those regions and languages. In this article, we will show you how to easily add hreflang tags in WordPress without writing a single line of code.

您是否要在WordPress帖子和页面中添加hreflang标签? 如果您以多种语言或不同地区发布内容,则hreflang标记可帮助您改善这些地区和语言的SEO。 在本文中,我们将向您展示如何轻松地在WordPress中添加hreflang标记而无需编写任何代码。

How to add hreflang tags in WordPress
什么是hreflang标签? (What is hreflang tag?)

Hreflang tag allows you to tell search engines which page to show for a particular region and language. You can also use it to define other variations of the same content in different languages.

Hreflang标记可让您告诉搜索引擎针对特定区域和语言显示哪个页面。 您还可以使用它来定义不同语言的同一内容的其他变体。

Here is how a hreflang tag implementation looks like in plain HTML.

这是hreflang标记实现在纯HTML中的外观。



<link rel="alternate" href="example.com" hreflang="en-us" />
<link rel="alternate" href="example.com/fr/" hreflang="fr-fr" />
<link rel="alternate" href="example.com/pt/" hreflang="pt-pt" />


The hreflang tag is a combination of the language code and the region code. For example, en-us for English and the United States, fr-fr for French and France, and so on.

hreflang标记是语言代码和地区代码的组合。 例如,en-us表示英语和美国,fr-fr表示法语和法国,依此类推。

WordPress is available in more than 60 languages, and you can use WordPress in your own language.

WordPress支持60多种语言,您可以使用自己的语言使用WordPress

Many WordPress site owners target users in different regions and languages. Some do that by creating multilingual websites, while others do that by offering some content in other languages.

许多WordPress网站所有者针对不同地区和语言的用户。 有些通过创建多语言网站来实现,而另一些通过提供其他语言来实现。

Search engines can easily detect the language of a page and automatically match it to the language settings on user’s browser. However, your pages may still be competing with each other in the search results which may affect your site’s SEO.

搜索引擎可以轻松地检测页面的语言,并将其与用户浏览器上的语言设置自动匹配。 但是,您的页面在搜索结果中可能仍然相互竞争,这可能会影响您网站的SEO。

You can implement hreflang tags to fix that. Let’s see how to easily add hreflang tags in WordPress.

您可以实现hreflang标记来解决此问题。 让我们看看如何在WordPress中轻松添加hreflang标签。

方法1:使用多语言插件在WordPress中添加hreflang标记 (Method 1: Add hreflang Tag in WordPress Using a Multilingual Plugin)

The best approach to building a multilingual WordPress site is by using a multilingual plugin. A multilingual WordPress plugin allows you to easily create and manage content in multiple languages using the same WordPress core software.

建立多语言WordPress网站的最佳方法是使用多语言插件。 多语言WordPress插件使您可以使用同一WordPress核心软件轻松创建和管理多种语言的内容。

These plugins will automatically take care of all technical things such as the hreflang tag, so you can focus on creating content.

这些插件将自动处理所有技术问题,例如hreflang标记,因此您可以专注于创建内容。

We recommend using Polylang. It is a free WordPress plugin and comes with a very powerful and easy to use interface to manage multilingual content. For detailed instructions, see our guide on how to how to easily create a multilingual WordPress site.

我们建议使用Polylang 。 它是一个免费的WordPress插件,并具有非常强大且易于使用的界面来管理多语言内容。 有关详细说明,请参阅有关如何轻松创建多语言WordPress网站的指南

Adding languages in Polylang

Another popular option is WPML. It is a premium WordPress plugin with an easy to use interface to create multilingual content on your website. For step by step instructions, see our guide on how to create a multilingual WordPress site with WPML.

另一个流行的选择是WPML 。 这是一个高级WordPress插件,具有易于使用的界面,可在您的网站上创建多语言内容。 有关逐步说明,请参阅有关如何使用WPML创建多语言WordPress网站的指南。

After you have created some posts or pages in multiple languages, you need to visit them in a new browser window. Right click and select ‘View Page Source’ from your browser menu.

创建多种语言的帖子或页面后,需要在新的浏览器窗口中访问它们。 右键单击并从浏览器菜单中选择“查看页面源”。

This will open the source code of the post or page. Now you need to look for hreflang tag to verify that it is working properly. You can also use CTRL+F (Command+F) keys to find the hreflang tag.

这将打开帖子或页面的源代码。 现在,您需要查找hreflang标记以验证其是否正常运行。 您也可以使用CTRL + F(Command + F)键查找hreflang标记。

方法2:在WordPress中添加Hreflang标记而不使用多语言插件 (Method 2: Add Hreflang Tags in WordPress Without Using a Multilingual Plugin)

This method is for users who are not using a multilingual plugin to manage translations on their websites.

此方法适用于不使用多语言插件来管理其网站上的翻译的用户。

First thing you need to do is install and activate the HREFLANG Tags Lite plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您需要做的第一件事是安装并激活HREFLANG Tags Lite插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, the plugin will add a new menu item labeled HREFLANG in your WordPress admin menu. Clicking on it will take you to the plugin’s settings page.

激活后,该插件将在您的WordPress管理菜单中添加一个标记为HREFLANG的新菜单项。 单击它会将您带到插件的设置页面。

hreflang tag plugin settings

Select the post types where you’d like to enable the plugin and then click on the save changes button to save your settings.

选择您要启用插件的帖子类型 ,然后单击“保存更改”按钮以保存设置。

Next, you need to edit the post or page where you want to add the hreflang tag. On the post edit screen, you will notice a new metabox labeled HREFLANG tags.

接下来,您需要编辑要在其中添加hreflang标记的帖子或页面。 在帖子编辑屏幕上,您会注意到一个新的带有HREFLANG标签的元框。

Adding hreflang tags using a plugin

First you need to add the URL of the post that you are currently editing and then select its language. After that you need to click on the plus button to add URLs of other variations of the post and their language.

首先,您需要添加当前正在编辑的帖子的URL,然后选择其语言。 之后,您需要单击加号按钮以添加帖子的其他变体及其语言的URL。

Once you are done, click on save or update button to save your post.

完成后,单击“保存”或“更新”按钮以保存您的帖子。

You can now visit your post in a browser window and view its source code. You will see the hreflang tag added to your post.

现在,您可以在浏览器窗口中访问您的帖子并查看其源代码。 您将看到hreflang标签添加到您的帖子中。

We hope this article helped you learn how to easily add hreflang tag to your WordPress site. You may also want to see our step by step WordPress SEO guide for beginners.

我们希望本文能帮助您学习如何轻松地将hreflang标记添加到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/plugins/how-to-add-hreflang-tags-in-wordpress/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值