How to display the unique content and images of a custom page (single page)?

Calendar 👁️ 62

In website operation, we often need to create some unique content and personalized page layouts, such as "About Us", "Contact Information", or a specific event detail page.AnQiCMS (AnQiCMS) provides us with powerful custom page (single page) functionality, which not only allows us to easily manage the text content of these pages, but also flexibly display their exclusive images and customized layouts.

How specifically can one operate to allow a custom page to have its own unique content and image display method?This mainly consists of several steps: first, create and edit a single page in the background, then make or choose a dedicated page template, and then skillfully call out these contents and images in the template, finally apply the template to the corresponding single page.

1. Create and manage custom pages (single pages) in the background

Everything starts with content. In the Anqi CMS backend, you can find the 'Page Management' feature under 'Page Resources'.Here, you can easily create a new page or edit an existing one.

When you add or edit a single page, you will see a series of fields that can be filled in:

  • Page Name: This is the title of your single page, which is usually displayed on the website front page.
  • SEO title, keywords, single page summaryThese are for search engine optimization, which can help your page get better rankings.
  • Single page contentThis is the core text content of the page, Anqin CMS provides a rich-featured editor, where you can format text and insert images just like writing an article.
  • Banner imageThis is a very practical feature, specially designed for uploading multiple images as banners or sliders on the page.When your "About Us" page needs a beautiful top image, or when the event page needs multiple promotional images, you can upload them here.
  • Thumbnail: If you need to display a representative image in some lists (such as page navigation or related recommendations) on your single page, you can upload it here.

After uploading the images and editing the content, there is no need to worry about their display issues for the time being; let's save these background data first.

Second, create or choose a dedicated page template.

By default, the custom page of Anqi CMS will use a name calledpage/detail.htmlThe general template. But if we want the "About Us" page to look different, we need to customize a template for it.

The template files of AnQi CMS are stored in/template/您的模板目录/below. For custom pages, you canpage/Create a dedicated template within the folder. There are several flexible naming methods:

  1. Universal single-page template:page/detail.htmlThis is the default template called for all single pages.
  2. Specify template by ID:page/detail-{单页ID}.htmlIf you want to create a template for a specific page with ID, for example, a single page with ID 10, you can name itpage/detail-10.html.
  3. Custom name templateThis is the most commonly used method, you can give the template a meaningful name, such aspage/about.htmlorpage/contact.html.

No matter which naming method is used, the template internally will use the Django-style template tags provided by AnQiCMS to call back-end data. Static resources such as CSS, JavaScript, and images are usually stored in/public/static/In the catalog and referenced in the template.

Chapter 3: Call the page-specific content and images in the template.

With a dedicated template file, the next step is to display the content edited on the back end and the uploaded images. Anqi CMS providespageDetailTags, it can be very convenient to get all the data on a single page.

In your custom page template (for example)page/about.html), you can call the title, content, and images of the page like this:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>{% pageDetail with name="Title" %}</title>
    <meta name="description" content="{% pageDetail with name="Description" %}">
    <meta name="keywords" content="{% pageDetail with name="Keywords" %}">
    <link rel="stylesheet" href="{% system with name="TemplateUrl" %}/css/style.css">
</head>
<body>
    {# 引用公共头部,如header.html #}
    {% include "partial/header.html" %}

    <main class="page-container">
        <h1 class="page-title">{% pageDetail with name="Title" %}</h1>

        {# 显示页面的Banner图组 #}
        <div class="page-banners">
            {% pageDetail pageImages with name="Images" %}
            {% for img in pageImages %}
                <img src="{{ img }}" alt="{% pageDetail with name="Title" %}" class="banner-image">
            {% endfor %}
            {% endpageDetail %}
        </div>

        {# 显示页面的缩略图(如果需要作为主图展示) #}
        {% pageDetail pageLogo with name="Logo" %}
        {% if pageLogo %}
            <div class="page-thumbnail">
                <img src="{{ pageLogo }}" alt="{% pageDetail with name="Title" %}" class="main-thumb">
            </div>
        {% endif %}
        {% endpageDetail %}
        
        <div class="page-content">
            {# 调用单页内容,注意使用 |safe 过滤器防止HTML被转义 #}
            {% pageDetail pageContent with name="Content" %}
            {{ pageContent|safe }}
            {% endpageDetail %}
        </div>
    </main>

    {# 引用公共底部,如footer.html #}
    {% include "partial/footer.html" %}
</body>
</html>

In the code above,{% pageDetail with name="Title" %}It will directly output the page name,{% pageDetail pageContent with name="Content" %}{{ pageContent|safe }}It will output the single page content you edit in the back-end editor, and|safeThe filter ensures that HTML code can be correctly parsed by the browser.

The most critical part is the image section:

  • {% pageDetail pageImages with name="Images" %}Used to obtain the image list you uploaded in the background "Banner Image". Since there may be multiple images, it is necessary to use{% for img in pageImages %}Loop to display them one by one.
  • {% pageDetail pageLogo with name="Logo" %}Then you can get the single image you uploaded in the background 'thumbnail'.

Through these tags, you can fully control the layout and display of page content.

IV. Apply the custom template to a single page.

The template file creation is complete, the final step is to associate this template with your single page.

Return to the 'Page Management' section of the AnQi CMS backend, edit the single page you want to apply the template to. In the editing page, find the page namedSingle page templateThe input box. Here, you need to enter the relative path and name of your custom template file.

For example, if the template file you create is/template/您的模板目录/page/about.htmlThen, in the "Single Page Template" field, you only need to fill inpage/about.htmlIt is done. After saving the settings, visit this single page, and you will see that it has been completely renewed, using your exclusive layout, content, and image display style.

By following these steps, you can make each custom page of Anqi CMS unique in charm, whether it is content or visual presentation, it can perfectly meet your operational needs.


Frequently Asked Questions (FAQ)

How to use different templates for different custom pages (single page)?You can create different template files for each single page that requires a unique design and name them using the "Custom Name Template" method, for examplepage/about-us.html/page/contact-us.html. Then edit the corresponding single page in the background and enter the corresponding template file name (such aspage/about-us.html)。This way, each page can have its own unique display style.

2. Why is my custom page content or image not displaying correctly on the frontend?There are some common reasons:

  • Template path is incorrect: Please check the path you filled in the "Single Page Template" field in the background to ensure it matches the actual template file path (for example, make sure that the path ends with the template file name)page/about.htmlReally exists/template/您的模板目录/page/Below).
  • |safeFilter missing: If your single page content contains HTML code (such as bold, links, images, etc.), it must be called in the template{{ pageContent }}must be added when|safeFilter, that is{{ pageContent|safe }}Otherwise, the system will default to escaping HTML codes, causing them to be displayed as text and not rendered normally.
  • Image path issueMake sure the image you uploaded is displayed normally in the background and the code that calls the image in the template is correct.If the image is uploaded to the local, the path is usually generated automatically;If it is an external image, ensure the URL is accessible.
  • Cache issueSometimes browser or system cache may cause changes not to be displayed in time, try clearing the browser cache or clicking 'Update Cache' in the AnQiCMS backend to view it again.

3. In addition to content and images, what information can be set on a custom page to benefit SEO?When creating or editing a custom page, you can fill in the fields 'SEO title', 'keywords', and 'single-page introduction' in the background. This information will be directly mapped to the page's HTML<title>Tag

Related articles

How to batch modify keywords in the article content in the background and synchronize them to the front display?

In website content operation, the accuracy and timeliness of keywords are crucial.With market changes or SEO strategy adjustments, we often need to make batch modifications to the keywords of a large number of articles on the website.If done manually, it will undoubtedly consume a lot of time and effort.幸运的是,AnQiCMS(AnQiCMS)提供了高效的批量关键词替换功能,让这一process变得得心应手,并能确保修改后的内容无缝同步到前台显示。

2025-11-07

How to use the `tagList` tag to display the associated tag (Tag) cloud of the article?

AnqiCMS provides a series of powerful and flexible tags to help us manage and display website content more efficiently.Among many features, the article tag (Tag) is a very practical feature that can effectively organize content, enhance the internal link structure of the website, and make it convenient for visitors to quickly find related topics of interest.Today, let's delve into how to use the `tagList` tag to elegantly display related tags in the AnqiCMS template, and even build a dynamic 'tag cloud'.

2025-11-07

How to use the `archiveFilters` tag to implement multiple condition combination filtering on the front end?

AnQiCMS provides flexible and powerful content management capabilities, one very practical feature is to use the `archiveFilters` tag to implement multi-condition combination filtering on the front-end.This undoubtedly greatly enhances the user experience and the discoverability of content for websites that are rich in content and require users to search for information based on different dimensions, such as product displays, real estate rentals, recruitment information, and so on.Let's delve deeper into how to use the `archiveFilters` tag to build an intuitive and efficient filtering system for your website.

2025-11-07

How to display website traffic statistics in the background in the form of charts?

In website operation, understanding and analyzing traffic data is a key link in formulating effective strategies and optimizing website performance.AnQiCMS (AnQiCMS) fully understands this, and therefore provides an intuitive and convenient traffic statistics function in the background, allowing operators to easily grasp all the data of the website in the form of charts, thereby better driving content and marketing decisions.The traffic statistics feature of Anqi CMS is designed to provide a comprehensive view of website performance.It not only records the user's visit behavior, but also pays special attention to the activities of search engine spiders, which is crucial for SEO work.Through the background data statistics module

2025-11-07

How to display the AnQiCMS built-in system language package switch feature on the front page?

AnQi CMS provides a flexible mechanism to allow your website to better serve users in different languages around the world.When you want to implement language switching on the front page, the tags and backend configuration built into AnQiCMS can well meet this need.Understanding AnQiCMS language package mechanism First, we need to clarify the concept of "language package" in AnQiCMS.The system language package built into AnQiCMS is mainly responsible for switching the website backend interface and the language of the**system built-in prompts, labels, etc.**on the front-end page.

2025-11-07

How to call and display the independent domain of the website backend configured in the template?

In the flexible content management system of AnQiCMS, site operators often need to display some key background configuration information in the website template according to business needs.Among the settings such as 'Background Independent Domain', it not only concerns the security of the system, but may also need to be displayed on the website front-end in certain scenarios, such as being used as a quick access entry for internal personnel, or for information explanation on specific pages. Today, let's delve into how to cleverly call and display the independent domain you have configured in the AnQiCMS template.###

2025-11-07

How to ensure that the website displays a custom prompt to users when it is in "shutdown" status?

In website operation, we sometimes encounter situations where we need to temporarily close the website, such as for system maintenance, major upgrades, data migration, or dealing with unexpected security events.For any reason, directly allowing users to access a blank page or an error page will severely affect user experience and even damage the brand image.At this time, it is particularly important to clearly display a friendly prompt message to visitors.

2025-11-07

How to display the number of comments for each article on the article list page?

In website operation, the article list page is not only the entrance of content, but also a window for users to understand the activity level of the website.When users see that every article is accompanied by a comment count, this not only effectively enhances the interactivity and attractiveness of the article, but also brings positive social proof to the website, encouraging more readers to participate in discussions.For users who use AnQiCMS, displaying the number of comments for each article on the article list page is a very direct and practical feature.

2025-11-07