As an experienced website operation expert, I am well aware that when carrying out global content layout,hreflangThe importance of correctly deploying tags for SEO is self-evident.It can effectively guide search engines to recognize the different languages or regional versions of your multilingual site, thereby displaying the most relevant content to users in different regions and avoiding potential duplicate content issues.hreflangcombining tags is the key to improving international operation efficiency.
Today, let's delve into how to accurately deploy in the HTML header of the AnQiCMS multilingual sitehreflangLabel.
Tame global traffic: AnQiCMS multilingual sitehreflangLabel's authoritative deployment guide
In today's world where globalization is increasingly becoming the main melody of enterprise development, building a multilingual website that can seamlessly reach users in different languages has become an indispensable path for content operations.AnQiCMS with its excellent multilingual support and multi-site management capabilities provides a solid technical foundation for enterprises.hreflangLabel.
hreflang: The silent messenger of global SEO
hreflangThe tag is not a direct ranking factor, but its contribution to Search Engine Optimization (SEO) is fundamental and profound. In simple terms, when your website has multiple language or regional versions of a page,hreflangJust tell Google, Bing, and other search engines: "Hey, this page has an English version, a Spanish version, and a French version specifically for French users!Through this method, the search engine can ensure that Spanish-speaking users see your website's Spanish version when searching, rather than other language versions, thus greatly enhancing the user experience, reducing the bounce rate, and avoiding the search engine mistakenly identifying different language versions as duplicate content and penalizing your site.
AnQiCMS in the project positioning clearly points out that it is 'aimed at becoming the preferred content management tool for small and medium-sized enterprises and content operation teams', and emphasizes its 'multi-language support' core feature, which can 'help enterprises expand into international markets and allow content to directly face users of different languages'. This is exactlyhreflangThe **scene where the label takes effect, AnQiCMS provides native support to simplify this process.
AnQiCMS in EnglishhreflangThe practical deployment of labels
Deployment in AnQiCMShreflangLabel, we mainly utilize its powerful template engine and built-inlanguagesLabel. BecausehreflangThe label needs to be placed on each page<head>Region, therefore the best practice is to configure it in the global template file of the site, ensuring that it can be applied automatically to all pages. Typically, this global template file is located/templatethe directory.base.htmlIt is either a common header file referenced by all pages (for example)partial/header.html).
AnQiCMS provides a namedlanguagesThe dedicated tag, its original design was to facilitate the retrieval of list information for multi-language sites.This tag does not require any parameters to traverse all configured multi-language sites under the current AnQiCMS instance.
First, let's take a look atlanguagesThe basic usage of the tag, it will return an array object containing information about all language sites:
{%- languages websites %}
{%- for item in websites %}
{# item.LanguageName: 站点语言名称 (如: English) #}
{# item.Language: 语言代码 (如: en, es-ES) #}
{# item.Link: 站点对应的完整链接地址 #}
{# item.LanguageIcon: 语言图标 #}
{# item.LanguageEmoji: 语言Emoji表情 #}
{%- endfor %}
{%- endLanguages %}
As you can see,item.Linkanditem.LanguageThese fields are exactly what we buildhreflangcore information for labeling.item.Linkcomplete URLs in different language versions, whileitem.Languageprovides language codes that comply with ISO standards (such asenrepresenting English,es-ES代表English-English)。
现在,我们将其整合到HTML的<head>Tags inside:
<!DOCTYPE html>
<html lang="{% system with name='Language' %}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% tdk with name="Title" siteName=true %}</title>
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">
{# 部署 hreflang 标签 #}
{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endLanguages %}
{# 如果有默认的语言或地区,可以额外添加 x-default 标签 #}
{# 例如,假设英语站点是你的默认回退版本 #}
<link rel="alternate" href="{% system with name='BaseUrl' %}" hreflang="x-default">
{# 其他 CSS 样式和 JavaScript 脚本 #}
<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
</head>
<body>
{# 页面内容 #}
</body>
</html>
In this code block:
- 我们利用
{%- languages websites %}标签,循环遍历了所有已配置的多语言站点。 - 在循环体内,通过
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">Structure, dynamically generates the correct one for each language version.hreflangLabel. item.LinkIt will automatically fill in the full URL of the language site.item.LanguageIt will be filled with the corresponding language code.- Especially note that,
hreflangtags必须包含当前页面自身的语言版本。AnQiCMS的languages标签会返回所有语言版本,包括当前语言,因此上述循环会自动覆盖这一要求。 - We also added an extra
hreflang="x-default"Label.This is a recommended **practice** that tells search engines which page version to display when there is no explicit language or region match.通常,这会是你主要的、或者说“默认的”语言版本,例如英语站点。{% system with name='BaseUrl' %}to get the main site URL asx-defaultlink.
Place this code in yourbase.htmlthe file<head>tags, AnQiCMS will automatically generate the correct one for all pageshreflangLabel.
Ensure deployment is foolproof: **Practical Tips and Important Reminders
- Maintain consistency:All
hreflangThe label set must be consistent on all related multilingual pages. This means that if page A has three versions A-en, A-es, A-fr,<head>English, must include these three versions,hreflangLabel. - The correct language and region codes:
hreflangThe value of the attribute must comply with ISO 639-1 (language) and ISO 3166-1 Alpha 2 (region) standards. For example, English isen, American English isen-USEnglish ises。If only the language is specified, all regions of that language will apply. In the AnQiCMS background settings, you will be required to select these standard codes to ensure the correctness of the output. - self-referencing tag:As described above, each page should contain a link to itself
hreflangtag to clearly indicate the language and region it belongs to. AnQiCMS'slanguagesLabel looping naturally meets this item. - Mutual link:
hreflangLabels are bidirectional.If page A-en points to page A-es, then page A-es must also point to page A-en.Otherwise, the search engine may ignore these tags.The global template deployment method of AnQiCMS ensures this. x-defaultThe use of:Consider adding one for your multilingual page set.hreflang="x-default"Properties. This page is the default display page when the search engine cannot find a more matching language or regional page for the user.- Scalability:Ensure all
hreflangThe URLs referenced in the tag are accessible, crawlable, and have not beenrobots.txtornoindexblocked by the tag. - Sitemap integration:Except for the HTML header, you can also specify in the XML sitemap (Sitemap) that
hreflangInformation. AnQiCMS provides Sitemap generation functionality, which ishreflangThe deployment provides another approach, but using HTML header tags is a more direct and universal practice.
Deployment through AnQiCMS's flexible template mechanism and built-in multilingual featureshreflangLabels are not difficult. Follow the above guidelines and **practice**, and you can effectively convey your intent to globalize your content to search engines, providing for users in different regions**.