How to display a custom page template independently on a specific page (such as About Us)?

Calendar 👁️ 59

Hello! During the process of building a website with Anqi CMS, we often encounter such needs: certain specific pages, such as "About Us", "Contact Us", or some special topic pages, require a layout and design that is completely different from the rest of the website.Fortunately, AnQi CMS provides a very flexible solution for this, allowing you to easily specify independent custom templates for these pages.

AnQi CMS, with its efficient features based on the Go language and support for Django template engine syntax, brings great convenience and customizability to content display.This means that even if you do not have a deep background in development, you can easily take simple steps to make your specific page have a unique visual style.

Why do we need independent page templates?

Imagine that most of the article pages on your website may follow a unified layout, with modular display of modules such as sidebars, content areas, and comment sections.When visitors click on This may include large background images, multi-column team introductions, specially designed milestone timelines, or embedded video content.Standard templates often fail to meet these personalized needs, at this point, an independent custom template can make your 'About Us' page stand out, and better convey brand information.

Overview of Anqi CMS template mechanism

In Anqi CMS, all front-end template files are stored in/template/the directory, and.htmlwith a suffix. Each template folder usually represents a set of themes. The system defaults to providing a generic template file for a single page, typicallypage/detail.htmlBut the powerful aspect of Anqie CMS is that it allows for more detailed template specifications for individual pages.

Next, we will take the "About Us" page as an example and guide you step by step on how to set up an independent custom template for it.

Step 1: Create your exclusive template file

Firstly, you need to find or create a subfolder namedpagein the directory of the template you are currently using. For example, if your template name isdefault, then the path is/template/default/page/. In thispageInside the folder, you can create a new HTML file namedabout.html. This file will contain all the unique design of your "About Us" page.

If you have already familiarized yourself with HTML and CSS, you can now start designingabout.htmlThe structure and style. You can design it to be completely different from the rest of the website, or make minor adjustments to the existing layout.

Second step: Design the template content and reference the page data

Inabout.htmlIn the file, you can use the template tags provided by Anqi CMS to dynamically refer to the content set in the background "Page Management".This way, you can still easily modify the page title, description, and main content information through the background, without having to directly change the template code.

For example, yourabout.htmlIt may include the following basic structure:

{% extends 'base.html' %} {# 假设您的主题有一个基础骨架模板 #}

{% block title %}
    {# 调用页面标题,并可选地附加网站名称 #}
    <title>{% tdk with name="Title" siteName=true %}</title>
{% endblock %}

{% block content %}
    <article class="about-us-section">
        {# 显示后台设置的页面标题 #}
        <h1 class="page-main-title">{% pageDetail with name="Title" %}</h1>

        {# 显示后台设置的页面描述 #}
        {% pageDetail pageDescription with name="Description" %}
        {% if pageDescription %}
            <p class="page-intro">{{ pageDescription }}</p>
        {% endif %}

        {# 显示后台设置的页面正文内容,记得使用 |safe 过滤器以正确渲染HTML格式 #}
        <div class="page-rich-content">
            {%- pageDetail pageContent with name="Content" %}
            {{ pageContent|safe }}
        </div>

        {# 您可以在这里添加更多自定义的HTML结构和内容 #}
        <div class="team-showcase">
            <h2>我们的团队</h2>
            <div class="team-members">
                {# 这里可以硬编码团队成员信息,或者通过自定义字段在后台管理 #}
                <div class="member">
                    <h3>张三</h3>
                    <p>创始人 & CEO</p>
                    <img src="/public/static/images/zhangsan.jpg" alt="张三" />
                </div>
                <div class="member">
                    <h3>李四</h3>
                    <p>市场总监</p>
                    <img src="/public/static/images/lisi.jpg" alt="李四" />
                </div>
            </div>
        </div>
    </article>
{% endblock %}

Please note,{% extends 'base.html' %}This line assumes that your theme has a namedbase.htmlThe basic template, which includes the common header, footer, and other elements of the website. This helps maintain the overall consistency of the website while allowing you to focus only on the unique content of specific pages.

Step three: Link the page with the custom template in the background

Design it wellabout.htmlAfter designing the template file, the key step is to link it with your "About Us" page.

  1. Log in to the AnQi CMS background.
  2. Find and click in the left navigation bar"Page Resources"and then select“Page Management”.
  3. Find the page you want to apply the new template in the single-page list, such as “About Us”, and click the rightEditbutton.
  4. After entering the page editing interface, scroll down and you will see a page namedSingle page templateInput box. Here, you just need to fill in the name of the custom template file you just created, for exampleabout.html.
  5. Click the bottom of the page.“OK”Button to save your changes

Step 4: Preview and adjust

After completing the above steps, you can access your "About Us" page on the front end. At this point, you should be able to see that the page has applied your designabout.htmlTemplate. If you find anything unsatisfactory, you can go back toabout.htmlModify in the file, then refresh the front-end page to see the real-time effect. The template system of Anqi CMS usually supports instant updates without complex compilation or restart operations.

Summary

By using the custom template feature provided by Anqi CMS, you can easily create a unique user experience for any specific page on the website.In order to meet brand stories, product introductions, or any other special needs, this flexibility greatly enhances the efficiency and effectiveness of content operation.Remember, the key is to create the correct template file path and specify the corresponding file name in the background, and Anqin CMS will take care of the rest of the rendering work.


Frequently Asked Questions (FAQ)

  1. Where should the custom page template file be placed so that it can be recognized by Anqie CMS?The custom template file you created should be placed in the theme currently being used.templateUnder the directorypageIn the folder. For example, if your theme name ismythemethen the file path should be/template/mytheme/page/您的模板名.html.

  2. What should I do if I modified the custom template file but the front page did not change?The template update of AnQi CMS is usually effective immediately. If you do not see any changes, please try clearing your browser cache first, or click the "Update Cache" feature in the AnQi CMS background.If it is still invalid, please check whether the path and file name of the template file are consistent with the name of the "Single Page Template" filled in the "Page Management" on the backend, including case sensitivity.

  3. How can I get the content filled in the background 'Page Management' in a custom page template, such as page title, text, etc?You can use{% pageDetail %}Template tags to retrieve this information. For example, to get the page title is{% pageDetail with name="Title" %}, to get the main content is{% pageDetail pageContent with name="Content" %}{{ pageContent|safe }}.|safeThe filter is very important, it ensures that HTML content is rendered correctly rather than displayed as plain text.

Related articles

How to get and display the Tag list of articles in the front-end template of AnQiCMS?

AnQiCMS as an efficient and flexible content management system, provides a wealth of features to help operators manage and display website content.Among them, the Tag tag function of the article is an important factor for optimizing content organization, improving user experience and SEO effects.Understand how to obtain and display these tags in front-end templates, which is crucial for building a website with comprehensive functions.### In AnQiCMS backend management tags Before delving into the front-end template, let's briefly review how tags work in the AnQiCMS backend

2025-11-07

How to implement keyword search and filtering display on article list or search result pages?

How to allow visitors to quickly find the content they need among the vast amount of information on our website is undoubtedly the key to improving user experience and the effectiveness of content marketing.AnQiCMS (AnQiCMS) knows this and therefore provides a powerful and flexible mechanism to help us easily implement keyword search and content filtering functions on article lists or search result pages.The implementation of this feature mainly revolves around the core template tags of AnQi CMS, allowing us to transform the content of the background management into a user-friendly interactive interface through the exquisite design of the frontend template.###

2025-11-07

How to add watermarks to images on the AnQiCMS website to protect original content?

In today's increasingly rich digital content, protecting the copyright of original works is particularly important, especially for visual content such as images.When your website publishes a large number of carefully crafted images, if they are not protected, it is easy for others to copy and repost them arbitrarily, which not only infringes on your labor results but also weakens the uniqueness of the content.Adding a watermark to an image is a simple and effective means of copyright protection, which can clearly assert ownership of the content without affecting the beauty of the image, effectively deterring unauthorized use.Anqi CMS as a highly efficient

2025-11-07

How to display the filing number and copyright information at the bottom of the website in AnQiCMS?

During the operation of a website, whether it is to meet the requirements of laws and regulations or to enhance the professionalism and user trust of the website, clearly displaying the filing number and copyright information at the bottom of the website is an important aspect.AnQiCMS as an efficient content management system provides a very flexible and intuitive way to configure and display these key information. Next, we will introduce step by step how to set and display the filing number and copyright information at the bottom of the AnQiCMS website.### The first step: Fill in the filing number and copyright information in the background First

2025-11-07

How to determine if a variable is empty in AnQiCMS template and display default content?

In website content operation, data integrity and the elegance of display are crucial.We often encounter such situations: some fields of data may be missing for various reasons, such as an article may not have an illustration, a product may not have a detailed description, or a custom field may not be filled in.If the template code does not perform the corresponding null value judgment, it may result in blank pages on the page, affecting the aesthetics, or may even cause template rendering errors, affecting the user experience.AnQiCMS with its efficient architecture based on the Go language and similar to Django

2025-11-07

How to implement safe output of HTML tags in article content to avoid XSS attacks?

In AnQiCMS, we not only pursue efficient and flexible content management, but also regard website security as a core element.In daily content creation and template development, a seemingly simple HTML tag output actually hides potential security risks, the most common of which is cross-site scripting (XSS) attack.Understanding how AnQiCMS processes HTML output and mastering security practices is crucial for building a robust and reliable website.How does AnQiCMS handle HTML content output?In AnQiCMS template rendering mechanism

2025-11-07

How to extract the article summary and add an ellipsis in AnQiCMS template?

In website operation, how to make the article list page both beautiful and informative is a common concern.Generally, we do not display the full content of the article on the list page, but instead use a short 'abstract' to attract readers to click.To maintain the cleanliness and professionalism of the page, these summaries often need to be automatically truncated when exceeding a certain length and appended with an elegant ellipsis.AnQiCMS is a powerful content management system that provides flexible tools in the template to help us meet this need.Below, we will discuss in detail how to use AnQiCMS

2025-11-07

How to display a list of website friend links in the front-end template?

In website operation, friendship links are not only a bridge between websites, but also an important strategy to enhance website authority, increase external traffic, and optimize search engine rankings.Reasonably configure and display friendship links, which can effectively improve the website's SEO performance and provide users with more valuable external resources.AnQiCMS as an efficient content management system, fully considers this need, and provides a simple and intuitive way to manage and display friend links in the front-end template.### Backend Management: Setting and Maintaining Friend Links Display Friend Links on the Front-end Page

2025-11-07