How to get the language configuration information of the current site using the `system` tag?

Calendar 👁️ 74

Anqi CMS template development: usingsystemIntelligent label to get the current site language configuration

As a senior website operations expert, I am well aware of the importance of multilingual support for corporate websites and content operations in today's global internet environment.AnQiCMS, this is an enterprise-level content management system based on the Go programming language, which fully considers this point from the beginning of the design, providing powerful multilingual support features to help users easily expand into the international market.But configuring the language only in the background is not enough. How to flexibly obtain and utilize these language configuration information in the front-end template is the key to bringing out its true value.systemLabel, and how to get the current site's language configuration information through it.

systemExploring the label: the Swiss Army knife for getting global configurations

In the AnQiCMS template system,systemThe tag plays a Swiss Army knife-like role, it is specifically used to obtain various global configuration information at the site level. From the website name, Logo, filing number, to copyright content, website URL, even template path, etc., all these basic settings throughout the website can be accessed throughsystemThe label can be easily accessed. Its purpose is to safely and efficiently pass the general information configured in the background to the front-end, for templates to render.

systemThe basic usage of tags is very concise and clear, usually we would use it in the form of{% system 变量名称 with name="字段名称" %}. Here is thenameThe property is core, it specifies the specific configuration item you want to obtain. For example, if you want to get the name of the website, you can write it like this:{% system with name="SiteName" %}If you need to assign the result to a variable for subsequent complex processing, you can specify a variable name, for example{% system siteName with name="SiteName" %}{{ siteName }}.

Accurate positioning:name="Language"power

When focusing on how to obtain the language configuration of the current site,systemlabel'snamethe attribute has a very intuitive and powerful option:Language.

That's right, you just need tosystemput in the tag.nameset the attribute to"Language",AnQiCMS will intelligently return the language code currently configured on the site. For example, if your site is configured as Simplified Chinese in the background, it may returnzh-cnIf configured to American English, it will returnen-usThese language codes follow international standards and have high recognition and practicality

Then, what is the value of this in practical application?

The most direct application scenario is to set the root tag of the HTML document<html>Dynamic settinglangProperties.This is a very important web standard practice, which not only helps search engines better understand the language of the page content, thus optimizing multilingual SEO effects, but also improves the compatibility of assistive tools such as screen readers, providing a better access experience for users with special needs.base.htmlOr set in the common header template:

<html lang="{% system with name='Language' %}">
  <head>
    <meta charset="UTF-8">
    <title>我的安企CMS站点</title>
    <!-- 其他头部内容 -->
  </head>
  <body>
    <!-- 页面主体 -->
  </body>
</html>

This line of simple code makes your website automatically adapt the correct language declaration according to the backend configuration.This not only simplifies template maintenance, but also enhances the professionalism and user-friendliness of the website without a trace.

Practical application and advanced thinking

Except for<html>Label settingslangAttributes, the language configuration information obtained is very useful in content operation and template development:

  • Dynamically loading language-related resources:You can load different CSS styles, JavaScript scripts, and even display different language versions of images or videos based on the current language.For example, a logo or thematic image of a specific country.
  • Conditional rendering of content:In some cases, you may need to display different text or functionality modules on the same page based on the language.systemThe language code returned by the tag can be used asifthe basis for logical judgment.
    
    {% if system.Language == "zh-cn" %}
        <p>欢迎来到中文站!</p>
    {% else %}
        <p>Welcome to our English site!</p>
    {% endif %}
    
  • Pass to JavaScript for use:If your front-end interaction logic needs to know the current page language, you can embed the language code in the JavaScript variable:
    
    <script>
        const currentLang = "{% system with name='Language' %}";
        console.log("当前站点语言是:", currentLang);
        // 基于 currentLang 执行其他 JS 逻辑
    </script>
    
  • The flexibility of multi-site management:AnQiCMS has a significant advantage in supporting multi-site management. If you need to retrieveanotherSite language configuration (for example, displaying language information of child sites in the navigation of a main site),systemLabels also support asiteIdparameter. By specifyingsiteIdYou can call the cross-site configuration, which is particularly useful for complex group websites or multi-brand operations.

In summary,systemlabel'sname="Language"An option provides a simple and powerful way for AnQiCMS template developers to programmatically obtain the language configuration of the current site.This not only improves the flexibility and maintainability of the template, but also lays a solid foundation for the globalization promotion, SEO optimization, and user experience of the website.Master and make good use of this tag, and it will give your AnQiCMS website operations a powerful boost.


Frequently Asked Questions (FAQ)

Question one: Where is the site language configuration of AnQi CMS set in the background?

Answer:In the AnQi CMS backend management interface, you can“Background Settings”Under the menuGlobal function settingsThe page finds and configures the default language package for the site. Here, multiple languages such as Chinese, English, and others are usually provided, and the language you choose will be set as the default language for the current site, and it can besystemThe label is obtained on the front end.

Question 2: Can I display a language switch list on the front-end template, so that users can easily switch to different language sites?

Answer:Of course you can. AnQiCMS provides a speciallanguagesLabel.This tag can retrieve the list of all configured multilingual sites, including their language names, language codes, and link addresses, etc.<a href="{{item.Link}}" hreflang="{{item.Language}}">{{item.LanguageName}}</a>to achieve the site's multilingual switching function.

Question 3: How should I operate to get the language configuration of the current site in Go backend logic?

Answer: systemTags are mainly used for front-end template rendering.In the Go language backend, AnQiCMS usually retrieves the language information of the current site through its internal configuration service or request context.GetSiteConfigorGetCurrentLanguageA function or method for business logic to call.If you carry out secondary development, you can refer to the AnQiCMS backend development documentation or source code to understand how to access these configurations from the Go code level.

Related articles

How to ensure the SEO-friendliness and standardization of AnQiCMS multilingual site URL structure?

As an experienced website operations expert, I fully understand the importance of multilingual sites in expanding the global market, as well as the profound impact of their URL structure on search engine optimization (SEO).AnQiCMS (AnQiCMS) provides strong support for implementing SEO-friendly and standardized multilingual URL structures with its efficient architecture based on the Go language.Today, let's delve into how to beautifully design the URL of a multilingual site in AnQiCMS, ensuring its performance in search engines.

2025-11-06

What are the specific advantages of AnQiCMS's multilingual module for expanding the international market of enterprises?

In today's globally interconnected business environment, companies want to break through geographical restrictions and expand into international markets. Multilingual websites are no longer optional, but a core strategic tool.A powerful content management system (CMS) plays a crucial role in it.AnQiCMS (AnQiCMS), as an enterprise-level content management system developed based on the Go language, its powerful multilingual module is the key driving force for enterprises to sail into the sea and achieve global growth.Eliminate language barriers, deeply link global users Imagine that

2025-11-06

How to configure different domain names for each multilingual site in AnQiCMS?

## AnQiCMS Multi-language Site Domain Configuration: Build a Global Content Base In the wave of globalization, it has become a norm for enterprises and self-media to provide content to users in different countries and regions.To enhance user experience, optimize search engine rankings (SEO), and establish an independent brand image, it is particularly important to configure independent domain names for each multilingual site.AnQiCMS as an enterprise-level content management system developed based on the Go language, with its powerful multi-site management and multi-language support capabilities, can help us easily achieve this goal

2025-11-06

Is the data between AnQiCMS multilingual sites shared or completely independent?

As an experienced website operations expert, I fully understand your concern for the multilingual functions and data processing mechanism of the content management system.When building an internationalized website, the way data is managed directly affects operational efficiency, content localization quality, and SEO effectiveness.The multi-language site data processing method for AnQiCMS (AnQiCMS) can be found from its core design philosophy and functional features.

2025-11-06

How does the `SiteName` field in AnQiCMS support multilingual title display?

Good, as an experienced website operation expert, I am happy to delve deeply into how the `SiteName` field in AnQiCMS supports multi-language title display and convert it into an article that is practical and easy to understand. --- ## AnQiCMS multilingual实战:How to accurately reach global users with `SiteName` title?

2025-11-06

How to get the configuration information of different multilingual sites using the `system` tag?

## The Anqi CMS Multilingual Site Operation Manual: Skillfully Using `system` Tags to Retrieve Configuration Information As a senior website operator, we are well aware that efficient content management and flexible configuration adjustments are the keys to success in the ever-changing network environment.AnQiCMS is an enterprise-level content management system developed based on the Go language, which provides us with great convenience with its powerful multi-site and multi-language support.Today, let's delve deeply into a seemingly simple but powerful template tag in AnQiCMS——`system`

2025-11-06

What is the role of the `siteId` parameter in AnQiCMS's multi-site management?

As an experienced website operations expert, I have a deep understanding of the powerful functions of AnQiCMS in actual operation, especially the exquisite design in multi-site management.Today, let's delve deeply into a seemingly minor but crucial parameter in AnQiCMS multi-site management, `siteId`. What role does it play, and how can we fully utilize it to optimize our content operation strategies.--- ### The core role and practice of the `siteId` parameter in AnQiCMS multi-site management AnQiCMS

2025-11-06

How to call language data from other sites in the AnQiCMS multi-site environment?

## Seamless Cross-Site Language Data Calling: AnQiCMS Content Operation Tool for Multi-Site Environment As an expert well-versed in website operations, I am fully aware of the challenges faced in managing content in multi-site, multi-language environments.Complex repetitive tasks, the trouble of data synchronization often make operators feel overwhelmed.However, AnQiCMS, with its powerful multi-site management and multi-language support capabilities, provides us with a graceful and efficient solution.

2025-11-06