How to get the current website's system configuration information in AnQiCMS template (such as website name, Logo)?

Calendar 👁️ 69

As an experienced website operation expert, I am happy to discuss with you how to efficiently and flexibly obtain the current system configuration information of AnQiCMS templates.This is not only the foundation of template development, but also the key to ensuring the uniformity and maintainability of website information.AnQiCMS is an enterprise-level content management system developed based on the Go language, its concise and efficient design philosophy is also reflected in the use of template tags, making the technical information in the template level call very intuitive.

Smart usesystemLabel: The all-purpose key for website information

In the AnQiCMS template system, you will find an extremely core and powerful tool - that issystemLabel. It is like a '万能钥匙' that can help you easily unlock and display the core configurations of the website, whether it is the website name, Logo image, or filing information, copyright statement, or even the global parameters you customize, all of which can be called through it in the template.

ThissystemThe basic usage of tags is very intuitive, its structure is usually like this:{% system 变量名称 with name="字段名称" %}Of course, if you just want to output the value of a field directly, you can omit变量名称part, just write it directly{% system with name="字段名称" %}. Here,nameThe attribute is the key information you tell the system which configuration information you want to obtain.

Next, let's take a look at some of the most commonly used and most representative ones.systemLabel practical value configuration information and its calling method.

Website name (SiteName): Your brand identification

The website name is the basic identity of each website. In the AnQiCMS background "Global Settings", you will set a name for your website, such as "AnQiCMS Official Website".When you need to display this name at the title, navigation bar, or footer of a website, you can use it.name="SiteName"to get:

{# 直接输出网站名称 #}
<h1>{% system with name="SiteName" %}</h1>

{# 将网站名称赋值给一个变量再使用,方便复杂场景 #}
{% system websiteName with name="SiteName" %}
<title>{{ websiteName }} - **内容管理系统</title>

This method avoids repeating the hard-coded website name in multiple template files, and once the backend is modified, the front-end will also automatically update, greatly improving maintenance efficiency.

Website Logo (SiteLogo): carrier of visual images

The logo is the visual soul of the website. In the AnQiCMS backend, you can upload the website's logo image.In the template, it is equally simple to retrieve and display this logo image:

{# 获取网站Logo的URL并显示,同时使用网站名称作为图片的alt属性 #}
<a href="{% system with name="BaseUrl" %}">
    <img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %} Logo">
</a>

Here we not only obtain the URL of the Logo image, but also combine the website name as the image'saltattribute, which is a very good practice for SEO and accessibility. At the same time,BaseUrlThe use of tags ensures that the Logo link always points to the homepage, even if the domain changes, no template modification is required.

Other important global configuration information

In addition to the website name and Logo,systemThe label can help you obtain many other important global configurations, which are indispensable when building a website:

  • Record number (SiteIcp)If your website has filing information, it is usually required to be displayed in the footer. You can call it like this:
    
    <p>
        <a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">
            {% system with name="SiteIcp" %}
        </a>
    </p>
    
  • Copyright content (SiteCopyright): The website footer usually contains copyright information. Considering that the copyright information may contain HTML tags (such as links), you may need to cooperate with|safeFilter to ensure the correct parsing of HTML content:
    
    {% system copyrightInfo with name="SiteCopyright" %}
    <p>{{ copyrightInfo|safe }}</p>
    
  • The home page address (BaseUrl)This configuration is very practical, especially when building navigation, breadcrumbs, or any links that need to point to the root directory of the website.It ensures that your link is always the correct absolute path in any environment.
    
    <a href="{% system with name="BaseUrl" %}">返回首页</a>
    
  • Static file address of the template (TemplateUrl): When developing templates, your CSS, JavaScript, and image static resources are usually stored in/public/static/In the directory and through/templateTemplates in the template folder.TemplateUrlThis will help you build the correct static resource path, ensuring that styles and scripts load correctly:
    
    <link rel="stylesheet" href="{% system with name="TemplateUrl" %}/css/style.css">
    <script src="{% system with name="TemplateUrl" %}/js/main.js"></script>
    
  • Site language (Language)This is for multilingual websites:<html>TaglangThe property setting is very useful, helping browsers and search engines to better understand the language used in the website content:
    
    <html lang="{% system with name="Language" %}">
    

Custom parameters: meet personalized needs

AnQiCMS's flexibility is also reflected in its ability to add custom parameters in the background "Global Settings". For example, you may have added a parameter named "Customer Service Phone" whose参数名is set toCustomerPhoneSo in the template, you can access it like built-in fields:

<p>客服热线:{% system with name="CustomerPhone" %}</p>

This allows AnQiCMS to easily adapt to various complex website operation requirements without modifying the core code.

Tips in practice

  1. Calling in a multi-site environmentIf you manage multiple sites in AnQiCMS and want to call the configuration information in the template of the current site,other sitesparameter.systemLabels also support asiteIdFor example, to get the ID of2write the site name like this:{% system with name="SiteName" siteId="2" %}This is very useful when building cross-site content or integrating services.
  2. Variable assignment and direct outputWhen you need to further process the configuration information you have obtained (such as concatenating strings, conditional judgments), it is recommended to assignsystemthe value obtained from the tag to a variable, for example{% system siteName with name="SiteName" %}If only to display simply, output directly is more concise.
  3. Debug and checkIf configuration information is not displayed correctly in the template, please first check whether the corresponding settings on the back-end have been saved, and then confirmnameIs the spelling of the attribute completely correct (case-sensitive). If necessary, clearing the AnQiCMS cache or browser cache may also be helpful.

By flexible applicationsystemLabel, you can manage and display your website information more efficiently and intelligently, allowing the powerful functions of AnQiCMS to be fully utilized in your template.


Frequently Asked Questions (FAQ)

  1. Q: Why did I set the website logo in the background, but it doesn't display in the template?<img src="{% system with name="SiteLogo" %}" ...>Why can't the image be displayed?A: This could be due to several reasons: first, please confirm that you have uploaded and saved the Logo image in the background "Global Settings".Next, check the network request to see if the image URL is correct and accessible.Sometimes, browser cache issues can also cause images

Related articles

How to implement string content replacement in AnQiCMS template?

As an experienced website operations expert, I know that flexibility and efficiency are the key to success in daily content management.How to quickly and accurately adjust the string content on the page in terms of content display, whether it is for SEO optimization, brand consistency, or to meet the ever-changing market needs, it is a core skill we must master.Today, let's delve deeply into how the AnQiCMS template cleverly implements the replacement function of string content, empowering your content operation.

2025-11-07

How to extract a specified part of a string or list in the AnQiCMS template?

In the daily operation of Anqi CMS, we often encounter scenarios where we need to display content in a refined manner.How to flexibly extract the part we want from a string or list, whether it is an article summary, product parameter list, or a user comment excerpt, is the key to improving user experience and page cleanliness.As an experienced website operation expert, I deeply understand the strength and flexibility of AnQiCMS based on Go language and Django template engine. Today, let's delve into how to accurately extract the specified part of a string or list in the AnQiCMS template.###

2025-11-07

How does the AnQiCMS template handle the escaping and unescaping of HTML content?

As an experienced website operations expert, I am well aware of the subtle balance between content safety and flexible display.In AnQiCMS such an efficient and secure content management system, understanding how its templates handle the escaping and unescaping of HTML content is crucial for building both aesthetically pleasing and secure user experiences.AnQiCMS is developed based on Go language, its template engine inherits many safety design concepts of modern web frameworks when processing HTML, including automatic escaping of HTML content.

2025-11-07

How to set a custom template for the document detail page or category list page of AnQiCMS?

As an experienced website operations expert, I am well aware that the flexibility and customizability of a content management system (CMS) are crucial for the long-term development of the website and the user experience.AnQiCMS (AnQiCMS) provides an excellent solution in this aspect with its powerful functions and ease of use.Today, let's delve into how to set up custom templates for your document detail page or category list page in AnQiCMS, making your website content display more personalized and professional.

2025-11-07

How to get the current page's TDK (Title, Description, Keywords) information in AnQiCMS template?

As an experienced website operation expert, I am well aware that TDK (Title, Description, Keywords) is crucial for the search engine optimization (SEO) of any website, as it is like the facade of the website and a guide for search engines.A meticulously optimized TDK that can make your website stand out in the vast sea of online information, attracting targeted users to click and bringing valuable traffic.

2025-11-07

How does the AnQiCMS template handle arithmetic operations on numbers?

Under the powerful system of AnQi CMS, content operation is far more than just piles of text and images.For modern websites, especially for e-commerce, data display, or scenarios requiring dynamic calculations, the ability to perform numerical operations directly in templates is particularly important.It makes our pages no longer static display boards, but intelligent interfaces that can respond in real-time to data.

2025-11-07

How to implement multilingual content switching and display in AnQiCMS templates?

As an experienced website operations expert, I am happy to delve deeply into the powerful capabilities of AnQiCMS in multi-language content switching and display.In today's increasingly globalized world, making website content accessible to users of different languages has become a key factor in expanding the market and enhancing brand influence for enterprises.AnQiCMS, as an efficient and customizable content management system, naturally it also provides a mature and flexible solution in this regard.

2025-11-07

How to implement unified management and content sharing for AnQiCMS?

In today's rapidly changing digital world, many enterprises and content operation teams find that simply having a website is no longer enough to meet their diversified business needs.No matter whether it is multi-brand operation, product line segmentation, regional market expansion, or multi-language promotion, efficiently managing multiple websites and achieving content collaboration is a huge challenge.AnQiCMS (AnQiCMS), as an enterprise-level content management system developed based on the Go language, was born to solve this pain point, it provides a set of elegant and powerful solutions, making it possible to manage multiple sites uniformly and share content

2025-11-07