How to correctly call and display the system configuration information in AnQiCMS templates?

Calendar 👁️ 73

Manage website content in AnQiCMS, not just publish articles and products, but also includes system-level configurations such as basic information, contact information, SEO metadata, etc.These configuration information is usually required to be displayed correctly on various pages of the website, such as displaying the website logo and name at the header, displaying the copyright and filing number at the footer, or displaying the company's phone number and address on the contact us page.Flexibly and correctly call these system configurations is the key to ensuring website information consistency, ease of maintenance, and SEO-friendliness.

AnQiCMS uses a syntax similar to the Django template engine, allowing template creators to refer to various background settings in a straightforward manner in the front-end template.

Call the system global configuration information

AnQiCMS provides a namedsystemThe template tag is specifically used to obtain various configurations from the background "Global Function Settings".Whether it is the website name, logo image address, record number, copyright information, or even the website access address and mobile end address, all of them can be easily called through this tag.

For example, if you want to display the website name<title>in the tag or show the Logo at the top of the page, you can write it like this:

<title>{% system with name="SiteName" %}</title>
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />

here,name="SiteName"Specified is the configuration item to obtain the website name,name="SiteLogo"which corresponds to the website logo.

And for the common footer copyright information, you may need to display the company name and the current year, along withSiteCopyrightandnowTags can be implemented:

<p>
    {% system with name="SiteCopyright" %} &copy; {% now "2006" %}. All Rights Reserved.
    <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a>
</p>

here,{% now "2006" %}It will dynamically display the current year, whileSiteIcpIt will display the filing number filled in on your backend. It should be noted that,nowin the label"2006"It is a time formatting reference time specific to the Go language, representing the year.

If your website has enabled a separate mobile domain or needs to reference static template files,BaseUrl/MobileUrlandTemplateUrlTags can be very useful:

<a href="{% system with name="BaseUrl" %}">网站首页</a>
{% if system.MobileUrl %}
    <a href="{% system with name="MobileUrl" %}">移动端访问</a>
{% endif %}
<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">

Combine when introducing CSS or JS static resources,TemplateUrlIt can effectively avoid path issues, making your template more universal.

Contact information configuration retrieval

The contact information of the website is usually displayed centrally, AnQiCMS provides special features for thiscontactThe tag allows you to conveniently obtain contact information, phone numbers, addresses, and email addresses from the background "Contact Information Settings".

On a typical "Contact Us" page or website footer, you can display it like this:

<p>联系人:{% contact with name="UserName" %}</p>
<p>电话:<a href="tel:{% contact with name="Cellphone" %}" rel="nofollow">{% contact with name="Cellphone" %}</a></p>
<p>邮箱:<a href="mailto:{% contact with name="Email" %}" rel="nofollow">{% contact with name="Email" %}</a></p>
<p>地址:{% contact with name="Address" %}</p>

If the background is set to WeChat QR code or custom WhatsApp contact information (added through custom parameters), it can also be called:

<img src="{% contact with name="Qrcode" %}" alt="微信二维码" />
<p>WhatsApp:{% contact with name="WhatsApp" %}</p>

Page TDK (Title, Description, Keywords) Information

The SEO optimization of the website cannot do without the setting of TDK. AnQiCMS providestdktags, allowing you to correctly call the<head>current page's title, keywords, and description in the template area.

In HTML's<head>inside the tag, you can place it like this:

<title>{% tdk with name="Title" siteName=true %}</title>
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">

here,siteName=trueIt is a very practical parameter that will automatically append the website name you set in the background to the page title, such as “Article Title - Your Website Name”, which helps maintain the unity of the title and brand exposure.

For more professional SEO needs, you may also need to use canonical links (Canonical URL), just like throughtdkTag retrieval:

{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}

We used a conditional judgment here{% if canonical %}This is a good template writing habit, which ensures that the corresponding HTML code is only output when there is a standard link.

Custom settings call

The AnQiCMS backend settings are very flexible, in addition to the built-in configuration items, you can also add custom parameters, such as a help page linkHelpUrlor an author nameAuthorThese custom parameters are passed throughdiytags to call.

For example, if you add a parameter named in the "Global Function Settings" or "Contact Information Settings" in the backgroundHelpUrland need to use it in the template:

<p>遇到问题?访问我们的<a href="{% diy with name="HelpUrl" %}" target="_blank">帮助中心</a></p>

This, when the background'sHelpUrlupdated, the front-end page will also synchronize automatically.

Multilingual Site Information

If your website has enabled the multilingual feature, AnQiCMS'slanguagesTags can help you build a language switcher or set uphreflangTags to adapt to international SEO needs.

Set up for search engines at the top of the pagehreflangIt can be like this:

{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endLanguages %}

Or build a language switch dropdown menu:

{%- languages websites %}
{%- if websites %}
<div>
    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}">
        {%- if item.LanguageIcon %}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}"/>
        {%- else %}
        {{item.LanguageEmoji}}
        {% endif %}
        {{item.LanguageName}}
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}

Template writing tips

When calling system configuration information in a template, there are some tips that can help you write more robust and secure templates:

  • |safeFilter:If the configuration content you call may contain HTML code (such asSiteCopyrightor certain custom parameters), be sure to use|safea filter. For example:{{siteCopyright|safe}}This is to inform the template engine that this part of the content is safe and does not need to be HTML-escaped, so that the HTML code can be correctly parsed by the browser.Please note that this means you need to ensure that the content is indeed safe to prevent potential XSS attacks.
  • Conditional judgment:For optional configuration items such asMobileUrlorCanonicalUrl, it is best to use{% if %}The tag is used for judgment. This can avoid unnecessary empty tags or error links on the page when the configuration item is empty, improving the cleanliness of page rendering.
  • Pay attention to case sensitivity:The AnQiCMS template tags are case-sensitive.SiteNameandsitenameThey will be considered as different fields, please make sure to spell the field names accurately according to the document provided.

By mastering the use ofsystem/contact/tdk/diyandlanguagesThese tags will allow you to fully utilize the flexible configuration capabilities of AnQiCMS to build a website that is rich in information, easy to maintain, and SEO-friendly.


Frequently Asked Questions (FAQ)

1. Why did the front-end page not update immediately after I modified the system settings in the background?This is usually because of the AnQiCMS caching mechanism. The system caches page content to improve performance.After modifying the background configuration, the cache needs to be cleared manually for the front-end to take effect immediately.You can find the 'Update Cache' feature in the AnQiCMS backend, click to execute it.

2. Can I directly retrieve and use these system configuration information in JavaScript?Cannot directly obtain through backend tags in JavaScript.Because template tags have already been parsed and outputted as HTML on the server side.If you need to use these configurations in JavaScript, **the practice is to output the data through hidden elements in HTML or JavaScript variables, and then JavaScript goes to read the data from these HTML.For example, you can add a hidden one to the page<input type="hidden" id="siteName" value="{% system with name='SiteName' %}" />Then in JavaScript, throughdocument.getElementById('siteName').valueGet it.

3. What tag should I use to display a custom field added in the background "Global Feature Settings"?For custom fields added in the "Global Feature Settings" or "Contact Information Settings", you should usediytags to call. For example, if you add a field namedServiceHotlineThe custom parameter, you can access it in the template like this:{% diy with name="ServiceHotline" %}Make sure thatnameThe parameter is exactly the same as the custom parameter name you set in the background.

Related articles

How to display common website elements, such as headers and footers, uniformly through template fragments (partial)?

When managing website content in Anqi CMS, you may find that many pages have similar structures, such as top navigation, footer copyright information, sidebar, or metadata tags, etc.If you have to write this code repeatedly for each page, it is not only inefficient, but also once you need to modify it, you have to search and update it page by page, which takes time and is prone to errors.Fortunately, Anqi CMS provides a very elegant solution - **template fragments (Partial)**, which helps us manage these common elements efficiently and uniformly.###

2025-11-08

How to customize the display template for specific documents, categories, or single pages?

When using AnQiCMS to manage website content, we often need to assign unique display styles and functional layouts to specific content types or unique pages.This kind of requirement is very common in content operation, for example, a product introduction page may need richer picture display and parameter comparison, while a news article focuses on the reading experience of text;Or it is the "About Us" page on the website, which needs to show a unique corporate culture.AnQi CMS provides flexible template customization features, allowing you to easily meet these personalized display needs

2025-11-08

How to choose the appropriate template type for the AnQiCMS website to optimize cross-device display effects?

It is crucial to ensure that the website displays well on different devices when building and operating a modern website.A website that provides a smooth experience on all screen sizes has become a norm as users access websites through various devices such as smartphones, tablets, and computers, not only improving user satisfaction but also helping to effectively disseminate content and optimize search engine rankings.AnQiCMS (AnQiCMS) offers various template types to meet this need, helping us flexibly deal with cross-device display challenges.

2025-11-08

How to ensure UTF-8 encoding of template files to avoid Chinese content from displaying garbled?

When using AnQi CMS to build and manage a website, you may encounter situations where Chinese content is displayed as garbled characters. This is usually not a problem with the system itself, but rather due to inconsistent encoding of template files.By ensuring that the template file uses UTF-8 encoding, you can completely resolve this problem, allowing the website content to be presented clearly and accurately to visitors. AnQi CMS was designed with the pursuit of efficiency, flexibility, and ease of use. It excels in supporting multiple languages and SEO optimization, and proper coding is the foundation for leveraging these advantages.

2025-11-08

How to dynamically display the contact information of the website in AnQiCMS templates?

In website operation, clearly and accurately displaying the website's contact information is a key link in building trust with users and providing support.A contact method that is easy to find and keep updated, which can not only improve the user experience but also help users find you quickly when necessary.AnQiCMS as an efficient content management system provides a very flexible and intuitive way for you to dynamically display and manage this important information in website templates.

2025-11-08

How to set and display search engine friendly TDK (Title, Description, Keywords) for AnQiCMS pages?

Search engine optimization (SEO) is an indispensable part of website operation, and the Title (title), Description (description), and Keywords (keywords) - abbreviated as TDK - of the website page are the foundation of SEO.They are the first step for search engines to understand page content and a key factor for users to decide whether to click on search results.

2025-11-08

How to implement a multi-level menu and content联动 display on the AnQiCMS website navigation list?

The website's navigation system is like the skeleton of a building, it not only guides users to browse but also directly affects the exposure of content and search engine optimization.AnQiCMS provides a flexible and powerful navigation management function, allowing you to easily build multi-level menus and achieve deep linkage with website content, thereby enhancing user experience and content distribution efficiency. ### Flexible configuration, build a multi-level navigation skeleton The starting point of implementing a multi-level menu in AnQiCMS is the navigation settings in the background.You can find all configuration items related to website navigation under the 'Background Settings' and 'Navigation Settings' first.

2025-11-08

How to display the title, category, time, and other core information on the AnQiCMS document detail page?

Manage website content in AnQiCMS, the document detail page is undoubtedly the core interface for users to obtain information.How to make this page both beautiful and informative is a concern for many website operators.Today, let's talk about how to elegantly display the title, category, publication time, and other key information on the document detail page of AnQiCMS.AnQiCMS uses a syntax similar to the Django template engine, which makes it very intuitive to call various data when customizing templates.

2025-11-08