Smart use of Anqi CMS's{% diy %}Label: Create a personalized global website title and subtitle
It is crucial to maintain the consistency of the brand image and the flexibility of content updates in website operation.Especially the global title and subtitle of the website, which are not only the first impression visitors have of the website content, but are also key elements for search engine optimization (SEO).{% diy %}Label, manage these core information easily without touching the code.
{% diy %}The charm of tags: a tool for customizing global content
When you need to set a unified,贯穿full-site brand title, or a subtitle that can be flexibly switched in specific scenarios (such as website maintenance, event promotion), the traditional hardcoding method is obviously not efficient. AnQi CMS's{% diy %}The tag is born for this. It allows you to customize any non-default global content in the website background and easily call it in the template, thus achieving highly flexible content display.
Used in AnQi CMS to call preset system information (such as website name, Logo, filing number, etc.){% system %}The tag is different,{% diy %}The tag focuses on youCustom creationThe parameter. This means that any text, link, or other information that you want to keep consistent across multiple pages of the website and may need to adjust at any time, can be{% diy %}Manage tags.
Set your custom title and subtitle in the Anqi CMS backend.
To pass.{% diy %}Label shows a custom website title or subtitle, and first you need to make simple configuration in the Anqi CMS backend.
- Enter the global function settings:Log in to your AnQi CMS backend, find and click on 'Global Settings' under 'Backend Settings' in the left navigation bar.
- Locate the custom settings parameters:On the 'Global Settings' page, you will see a section named 'Custom Setting Parameters'. This is where you create personalized global content.
- Add a new parameter:Click the 'Add Parameter' button to create a new custom item.
- Parameter name:This is the field name you use when calling the template. It is recommended to use English and Anqi CMS will automatically convert it to camel case (i.e., the first letter of each word is capitalized, such as "main title" will automatically become
MainTitle)。You can set a parameter name for the global main title, for exampleGlobalMainTitle,to set the subtitleGlobalSubTitle. - Parameter value:Enter the specific title or subtitle content you want to display on the website. For example,“}]
GlobalMainTitleThe parameter value can be "AnQi CMS: An Efficient Content Management Expert".GlobalSubTitleThe parameter value can be "Helping small and medium enterprises easily manage websites". - Note:Enter a brief description to facilitate the management and understanding of the parameter's purpose in the future.
- Parameter name:This is the field name you use when calling the template. It is recommended to use English and Anqi CMS will automatically convert it to camel case (i.e., the first letter of each word is capitalized, such as "main title" will automatically become
After adding, save your settings. Now, these custom global content has already been stored in Anqicms, waiting for you to call it in the template.
Integrated in the template{% diy %}Label display title and subtitle
Once custom parameters are defined in the background, the next step is to integrate them into the website template so that they can be presented to users. Anqie CMS templates follow a syntax similar to the Django template engine, using{% diy %}Label calling custom content is very intuitive.
Here is what you can use in the template file (for example, the header file)header.htmlorbash.htmlor the homepageindex.html){% diy %}in the way of tags:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>{% diy with name="GlobalMainTitle" %} - {% diy with name="GlobalSubTitle" %}</title>
<!-- 其他头部信息 -->
</head>
<body>
<header>
<h1>{% diy with name="GlobalMainTitle" %}</h1>
<p class="subtitle">{% diy with name="GlobalSubTitle" %}</p>
<!-- 网站导航等其他内容 -->
</header>
<!-- 网站主体内容 -->
</body>
</html>
In the above example:
- We pass
<title>The tag displays the main title and subtitle in the webpage title, separated by a hyphen. - In
<h1>and<p>The tag displays the custom main title and subtitle separately.
If you want to{% diy %}Assign the value obtained from the label to a variable for more complex logical processing, or you can also do this:
{% diy mainTitle with name="GlobalMainTitle" %}
{% diy subTitle with name="GlobalSubTitle" %}
<title>{{ mainTitle }} - {{ subTitle }}</title>
This method is very useful when it is necessary to further filter, combine, or make conditional judgments on these title contents.
For users with multiple sites, if they need to call data from other sites, they can{% diy %}the tagsiteIdparameters, for example{% diy with name="GlobalMainTitle" siteId="2" %}, but this is unnecessary in most single-site cases.
use{% diy %}the advantages of the tag and **practice
By{% diy %}Label management of the global website title and subtitle, you will gain the following significant advantages:
- Centralized management:All global text information can be set and modified in the background, avoiding the麻烦 of modifying multiple template files.
- Flexibility and timeliness:When the website title or subtitle needs to be updated, just modify the parameter value in the background and save it, and it will take effect in real time without redeploying the code.
- SEO friendly:Maintain the consistency and ease of updating of the website title and subtitle, which helps improve the website's search engine performance.
- Lower the technical threshold:The operation staff does not need to have programming knowledge and can easily maintain the core text information of the website.
**Practical suggestions:
- Meaningful parameter names:Use clear and descriptive English parameter names, for example
BrandSlogan/SeasonalGreetingInstead of vague,.Text1/Text2. - Reasonable planning:Plan which contents need to be managed as global custom parameters at the beginning of website construction to improve efficiency.
- Regular review:Regularly check the content of custom parameters to ensure their timeliness and accuracy.
Of Security CMS{% diy %}Tags bring great convenience and flexibility to website operation.Master and make good use of this feature, and you will be able to manage website content more efficiently and accurately, enhance user experience and brand influence.
Frequently Asked Questions (FAQ)
Q1:{% diy %}Tags and{% system %}What are the differences between tags? How should I choose?
A1:{% system %}Tags are used to call the Anqi CMS systemPre-setGlobal configuration items, such as "Website Name" (SiteName)、“Website Logo”(SiteLogo)、“Record Number”(SiteIcp)etc. These are built-in, CMS-specific settings.{% diy %}Tags are used to call the "Global Settings" in the backgroundCustom creationThe parameter. If you need a text, link, or other data that is not preset by the system but you want to manage and call it uniformly across the entire site, you should use{% diy %}In short,systemUsed to obtain fixed system-level information,diyUsed to obtain personalized information defined by you.
Q2: Besides the website title and subtitle, I can also use{% diy %}What other types of content does the tag management handle?
A2:{% diy %}The use of labels is very extensive.Any text or short code snippet that you wish to repeat in multiple locations on the website and may need to modify flexibly can be managed through it.For example, you can customize a 'customer service phone' parameter, a 'company email' parameter, a 'friend link recommendation' parameter, and even a 'holiday greeting' parameter for a specific festival.In this way, you can manage all this variable but unified content centrally, greatly improving the maintenance efficiency of the website.
Q3: If I set a custom parameter name in the background that is not camel case, such as "Website Main Title", how should I call it in the template?
A3: The AnQi CMS handles this problem very intelligently. When you enter a parameter name (such as "Website Title") in the "Custom Settings Parameters" under the "Global Settings" in the background, the system will automatically convert it to camel case (WangZhanZhuBiaoTiOr a more reasonable camel case naming (if you enter English but with spaces, such as "main title" it will be converted toMainTitleTherefore, even if you use Chinese parameter names or English parameter names with spaces in the background, please try to use their corresponding camel case names when calling them in the template (for example,{% diy with name="WangZhanZhuBiaoTi" %}or{% diy with name="MainTitle" %})。通常,the system will prompt you for the converted parameter name.