As an experienced website operation expert, I am well aware that when carrying out global content layout,hreflangThe correct deployment of tags is of great importance to SEO.It can effectively guide search engines to recognize the different language or regional versions of your multilingual site, thereby displaying the most relevant content to users in different regions and avoiding potential duplicate content issues.For AnQiCMS such a powerful and highly flexible content management system, understanding its multilingual features andhreflangcombining tags together 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 sitehreflang.
Harness global traffic: AnQiCMS multilingual sitehreflangThe authoritative deployment guide of the label
Today, as globalization is increasingly becoming the main melody of enterprise development, building a multilingual website that can seamlessly reach different language users has become an essential path for content operation.AnQiCMS with its excellent multilingual support and multi-site management capabilities provides a solid technical foundation for enterprises.However, having multilingual content is just the first step, how to make search engines correctly understand these contents and deliver them to the target users requires a crucial SEO signal -hreflang.
hreflangThe silent messenger of global SEO:
hreflangTags are not a direct ranking factor, but their contribution to search engine optimization (SEO) is fundamental and profound. Simply put, when your website has multiple language or regional versions of a page, hreflangTell GoogleIn this way, the search engine can ensure that when Spanish-speaking users search, they see the Spanish version of your website, not other versions, thereby greatly enhancing user experience, reducing bounce rates, and avoiding the search engine mistakenly judging different language versions as duplicate content and penalizing your site.
AnQiCMS clearly states in its project positioning that it aims to become the preferred content management tool for small and medium-sized enterprises and content operation teams, and emphasizes its core function of "multilingual support", which can help enterprises expand into international markets and enable content to directly face users of different languages. This is exactlyhreflangThe **scene where the label plays a role, AnQiCMS provides native support to simplify this process.
AnQiCMS inhreflangThe practical deployment of labels
Deployment in AnQiCMShreflangLabel, we mainly utilize its powerful template engine and built-inlanguagesLabel. Due tohreflangLabels need to be placed on each page.<head>The area, therefore, the best practice is to configure it in the global template file of the site to ensure it is automatically applied to all pages. Typically, this global template file is located/templateUnder the directorybase.htmlOr it is the public header file referenced by all pages (for examplepartial/header.html)
AnQiCMS provides a namedlanguagesA dedicated tag, its original intention is to facilitate the retrieval of a list of multilingual site information.This tag does not require any parameters and can traverse all the multi-language sites configured 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 buildhreflangthe core information needed for labeling.item.LinkIt provides complete URLs in different language versions, whileitem.Languageit provides language codes that comply with ISO standards (such asenrepresenting Englishes-ESRepresents Spanish-Spain).
Now, we integrate it into the HTML's<head>tags:
<!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:
- We use
{%- languages websites %}Tag, loops through all configured multilingual sites. - In the loop body, through
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">Structure, dynamically generates the correct one for each language version.hreflang. item.LinkWill be automatically filled with the complete URL of the language site,item.LanguageIt will be filled with the corresponding language code.- Special attention should be paid to the fact that,
hreflangTagThe current page's language version must be included. AnQiCMS'languagesThe tag will return all language versions, including the current language, so the above loop will automatically override this requirement - We have also added an extra one
hreflang="x-default"Label. This is a recommended **practice that tells the search engine which page version to display when there is no explicit language or regional match.This is typically your main, or "default" language version, such as an English site.Here I use{% system with name='BaseUrl' %}To get the main site URL asx-defaultlink.
Place this code in yourbase.htmlthe file<head>tag, AnQiCMS can automatically generate the correct one for all pageshreflang.
Ensure deployment is impenetrable: **Practical Tips and Important Notes
- 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, then the pages A-en, A-es, A-fr must be consistent.<head>These must include all three versionshreflang. - Correct language and region codes:
hreflangThe value must comply with the ISO 639-1 (language) and ISO 3166-1 Alpha 2 (region) standards. For example, English isen, American English isen-US, Spanish isesIf only the language is specified, then all regions of that language will apply. In the AnQiCMS backend settings, you will be required to select these standard codes to ensure the correctness of the output. - Self-referential tag:As mentioned above, each page should contain a link
hreflangto itself to clearly indicate the language and region. AnQiCMS'languagesThis tag naturally satisfies this item. - Mutual link:
hreflangThe label is bidirectional. If page A-en points to page A-es, then page A-es must also point to page A-en.Otherwise, search engines may ignore these tags. The global template deployment method of AnQiCMS ensures this. x-defaultUsage:Consider adding one to your multilingual page set.hreflang="x-default"Property. This page is the default display page when the search engine cannot find a more matching language or regional page for the user.- Crawlability:Ensure all
hreflangLabels refer to URLs that are accessible, crawlable, and notrobots.txtornoindexblocked by labels. - Sitemap integration:Except for the HTML header, you can also specify in the XML sitemap (Sitemap)
hreflanginformation. AnQiCMS provides Sitemap generation functionality, which is forhreflangThe deployment provides another way, but the direct and universal approach is to use HTML header tags.
Deployed through the flexible template mechanism and built-in multilingual functionality of AnQiCMS,hreflangLabels are not difficult. By following the above guidelines and **practice, you can effectively communicate your intent for global content to search engines and provide for users in different regions**.