How to create and apply an independent template for a specific single page (such as 'About Us')?

Calendar 👁️ 57

As an experienced website operator who deeply understands the operation of AnQiCMS, I understand that you want to create and apply an independent template for a specific single page (such as "About Us").This can not only make the page content display more personalized, but also effectively meet specific design and functional requirements.AnQiCMS provides a flexible template mechanism, making this process intuitive and efficient.

Create and apply a detailed guide for an independent template for a specific single-page of Anqicms

AnQiCMS with its high customizability and flexibility, allows website operators to easily meet the diverse needs of content display.Creating and applying independent templates is an effective way to enhance user experience and brand image for single-page websites that have unique styles or structures.This guide will elaborate on how to create and apply a custom template for a specific single page in AnQiCMS.

Step 1: Create a custom template file

In AnQiCMS, all template files are stored in the root directory of the website./templateIn the folder. First, you need to enter the directory of the currently used template theme. Under the theme directory, according to the AnQiCMS convention, the custom templates for single pages are usually stored inpage/In the subdirectory.

You cantemplate/[您的主题目录]/page/Create a new HTML file in the path, for example, if you want to create an independent template for the "About Us" page, you can name itabout.html. Therefore, the complete file path might betemplate/[您的主题目录]/page/about.html.

This new HTML file will serve as the exclusive template for your "About Us" page. In the file, you can introduce the basic layout according to your design needs (via{% extends 'base.html' %}or{% include 'partial/header.html' %}In order to define the structure of the content area, AnQiCMS stipulates that the styles, JS scripts, images, and other static resources used by the template should be stored separately./public/static/Table of contents, and reference it correctly in the template.

Step two: write the template content.

Inpage/about.htmlIn the file, you can start writing the specific page structure and dynamic content.AnQiCMS supports Django template engine syntax, allowing you to easily insert page titles, content, images, and other system information.

For example, to get the title, description, and main content of the 'About Us' page, you can usepageDetailLabel. You can also call global system information, contact information, or navigation list, etc.

Here is an example template code snippet:

{% extends 'base.html' %} {# 继承您的基础模板,确保页面包含统一的头部、底部等元素 #}

{% block title %}
    {# 获取页面的SEO标题,并附加网站名称,提升搜索引擎友好性 #}
    <title>{% tdk with name="Title" siteName=true %}</title>
    {# 获取页面的SEO关键词 #}
    <meta name="keywords" content="{% tdk with name="Keywords" %}">
    {# 获取页面的SEO描述 #}
    <meta name="description" content="{% tdk with name="Description" %}">
{% endblock %}

{% block content %}
    <div class="about-us-container">
        {# 使用pageDetail标签获取当前单页面的标题 #}
        {%- pageDetail pageTitle with name="Title" %}
        <h1>{{ pageTitle }}</h1>

        {# 使用pageDetail标签获取当前单页面的主要内容 #}
        {%- pageDetail pageContent with name="Content" %}
        <div class="about-content">
            {# 输出内容时,使用safe过滤器防止HTML标签被转义,确保页面样式正确渲染 #}
            {{ pageContent|safe }}
        </div>

        {# 示例:集成系统预设的联系方式,避免在模板中硬编码 #}
        <div class="contact-info">
            <h2>联系我们</h2>
            <p>电话: {% contact with name="Cellphone" %}</p>
            <p>邮箱: {% contact with name="Email" %}</p>
            <p>地址: {% contact with name="Address" %}</p>
        </div>
    </div>
{% endblock %}

In this example,pageDetailThe tag is used to dynamically retrieve the title and content of the current single page.tdkThe tag is used to set the SEO title, keywords, and description of the page.contactLabels are used to display preset contact information. Please note that when outputting content that includes HTML tags (such aspageContent), be sure to use|safeA filter to ensure that HTML content is rendered correctly rather than being escaped.

Step 3: Apply custom templates in the background

After the template file is created and written, the next step is to apply this template to your "About Us" page in the AnQiCMS backend.

Log in to the AnQiCMS admin panel, navigate toPage resources -> Page management.

Here, you can find or create your 'About Us' page. Click edit to enter the page details.

Scroll down in the page editing form to find the field namedSingle page templateThe field. In this input box, enter the relative path of the custom template file you just created, for examplepage/about.htmlThe AnQiCMS system will look for and render your custom template based on this path.

Confirm all information is correct before clicking the save button. AnQiCMS will associate this custom template with the 'About Us' single page according to the path you enter.

Step 4: Preview and Optimize

After completing the above steps, you can visit the "About Us" page through your browser

Related articles

How to customize the document list template for a specific category?

As a website operator who deeply understands the operation of AnQiCMS, I understand your needs for personalized content display and user experience optimization.The document list template under the custom category is the key step to achieve this goal.AnQiCMS provides a flexible template mechanism that allows you to present a unique list layout based on the content features of specific categories.

2025-11-06

What are the naming conventions to follow for a specific document detail page template?

As an experienced security CMS website operations personnel, I deeply understand the importance of the naming rules of the content management system (CMS) template for the long-term operation, maintenance efficiency, and content presentation quality of the website.A clear and standardized template naming not only allows team members to quickly understand the purpose of the file, reduce collaboration costs, but also provides strong flexibility and scalability when the website faces a redesign or feature upgrade.In AnQi CMS, the naming of templates for specific document detail pages follows a set of flexible and hierarchical rules, aimed at meeting the needs of content display at different granularity.

2025-11-06

How can I implement a custom template name so that the system can automatically recognize and apply it?

As an experienced security CMS website operator, I am well aware of the importance of flexible template customization for website content display and user experience.The Anqi CMS, with its concise and efficient architecture, provides us with great freedom to manage and display content.How to implement a custom template name so that the system can intelligently recognize and apply it is the key to improving operational efficiency and meeting the needs of personalized display.

2025-11-06

Where should the mobile template files be stored in a specific subdirectory?

As a senior security CMS website operation personnel, I fully understand the core position of content in user experience, and providing optimized content display for different devices is the key to retaining users.When it comes to the mobile template management of AnQi CMS, specifying the storage location of the template files is crucial for efficient content publishing and maintenance.In AnQi CMS, in order to adapt to the display of mobile devices, the system provides a specific mechanism to manage the template files for the mobile end.

2025-11-06

How to define a new template, what is the role of the `config.` file?

As an experienced CMS website operation personnel, I am well aware that a flexible and efficient template system is crucial for the presentation of website content and user experience.The AnQi CMS was designed with full consideration of the customizability and ease of use of the templates, allowing both beginners and experienced developers to easily handle it.Next, I will elaborate on how to define a new template in Anqi CMS and deeply analyze the core role played by the `config.` file in this process.

2025-11-06

What are the possible values and their meanings for the `template_type` field in `config.`?

As an experienced CMS website operation personnel, I fully understand the importance of template configuration for the front-end display and user experience of the website.The `config.` file is the core configuration file for each AnQiCMS template, defining its various basic properties and behaviors.Among them, the `template_type` field plays a crucial role, directly affecting the display of the website on different devices.

2025-11-06

How to control the enable status of the template through the `status` field in `config.`?

In the daily operation of Anqi CMS, we often need to adjust the appearance and layout of the website, which usually involves switching or enabling different templates.AnQi CMS provides an intuitive and efficient way to manage the enabled status of templates, which is mainly achieved through the `status` field in the `config.` file under each template directory.

2025-11-06

How should common code snippets like headers, footers, etc. be organized and stored during template creation?

As a website operator familiar with Anqi CMS, I am well aware of the importance of a well-structured and easy-to-maintain template for the long-term healthy operation of the website.How to efficiently organize and store common page headers, footers, and other reusable code snippets during template creation is crucial for improving development efficiency and ensuring website consistency.In Anqi CMS, the template system uses a syntax similar to the Django template engine, which provides us with powerful tools to achieve code reuse and modular management.

2025-11-06