I want to set up an independent display template for a specific document, where should this custom template file be placed?

Calendar 👁️ 58

As an experienced website operations expert, I know the importance of a flexible content management system for personalized website display.AnQiCMS (AnQiCMS) performs very well in this aspect, allowing us to set independent display templates for specific content, which undoubtedly provides us with great freedom in content marketing and user experience optimization.Where should the custom template file be placed when we want to design a unique display style for a specific document (such as an article, a special product page, or a special single page)?Today, let's delve deeply into this issue.

The foundation of AnQi CMS template files:/templateTable of contents

Firstly, we need to clarify the template files of Anqi CMSroot directory.No matter which theme template you use, they are all stored in the Anqi CMS installation directory./templateIn the folder. In this/templateDirectory, you will see one or more subfolders named with topic names, such asdefault. Any custom template files you create should be placed inThe currently enabled theme template folderwithin. For example, if your theme name ismythemethen your custom template file will finally exist in/template/mytheme/the directory or its subdirectories.

The location and naming of custom template files under the two main scenarios

AnQi CMS provides two main mechanisms to specify display templates for specific documents, these two mechanisms determine how your custom template files should be named and placed:

Scenario one: Intelligent recognition based on content ID or alias

AnQi CMS has a "agreement first" intelligent recognition mechanism.This means that if you place template files according to specific naming conventions, the system can automatically match and apply these templates to the corresponding documents without any additional settings in the background.

  1. ID matching for general documents (such as articles, products):When you need to set an independent template for a document with a specific ID (for example, an article or product with ID 123), you can name the template file:{模型table}/{文档id}.htmlFor example, if your article model corresponds to the table namedarticleand you want to create an independent template for the article with ID123then you can name the file asarticle/123.htmlplace it in the root directory of the current theme template (i.e.),/template/mytheme/article/123.htmlThe system will automatically load this exclusive template when accessing this article with ID 123.

  2. For matching ID or alias on a single page:A single page is a common special content type on a website, such as "About Uspage/{单页面id}.htmlorpage/{单页面别名}.htmlFor example, if you have a page with an ID of15, the template file can be namedpage/15.html. If you have set a custom URL alias for the "About Us" page in the background,about-usThen you can create a file namedpage/about-us.htmltemplate file. When the system accesses the single page, it will first search and apply this specific template.

The advantage of this intelligent recognition is that once the file is in place, the system can automatically associate and simplify the background configuration process.

Scenario two: Flexibly specify through the background "document template" field.

In addition to intelligent recognition, Anqi CMS also provides a more flexible way, allowing you to manually specify a custom template on the document editing page.This method is applicable when the template file name does not follow the ID or alias naming rules, or when you want to apply the same template to multiple different ID documents.

When editing a document (article, product, page), you will find a named parameter in the "Other Parameters" or "Advanced Settings".Document TemplateThe field (the specific name may vary slightly depending on the version of Anqicms, but it refers to the same thing).Here, you can directly fill in the path and filename of the custom template file relative to the root directory of the current theme template.

  • Location of the template file: Your custom template file still needs to be placed in the template folder of the current theme/template/mytheme/Inside.
  • Example of template file name:
    • If you place the file directly in the root directory of the theme template (for example/template/mytheme/download.html), then you just need to fill in the "Document Template" fielddownload.html.
    • If you have created subdirectories (for example, to organize templates/template/mytheme/custom/product-offer.html), then you need to fill in the "Document Template" fieldcustom/product-offer.html.

The flexibility of this method lies in the fact that you can create a universal template for a set of documents that have common display requirements (such aspromotion-detail.html), then just specify the template file in the background of each relevant document.

Actual Operation Suggestions and **Practice

  1. Unified theme folder:Always place all your custom template files in the current active theme template folder. Do not directly modify the Anqie CMS core./templateThe directory or default theme, as this may cause the file to be overwritten after update.
  2. Clear directory structure:In order to facilitate management and maintenance, I strongly recommend that you create a logically clear subdirectory within the theme template folder. For example:
    • article/: Stores all templates related to articles.
    • product/: Store all product-related templates
    • page/: Store all single-page related templates
    • partial/: Store reusable code snippets, such as headers, footers, and sidebars
    • custom/: Store those general custom templates that do not belong to a specific model but need to be manually specified
  3. Use.htmlExtension name:Anqi CMS template files are unified in use.htmlAs the file extension.
  4. UTF-8 Encoding:Ensure all template files are saved in UTF-8 encoding to avoid Chinese garbled text issues.
  5. Precision of background fields:If you choose to manually specify the template through the background field, please make sure that the path and filename you enter match the actual file exactly, including case and file extension, otherwise the system will not be able to find the corresponding template.
  6. Test is for the king:Always test the document page on the front end after creating or modifying a custom template and associating it with a specific document to ensure the display effect meets expectations.

By using these flexible template specifications and organization methods provided by Anqi CMS, you can easily create unique and engaging display effects for any content on your website, thereby better serving your website operation goals.


Frequently Asked Questions (FAQ)

  1. Q: If I set a template based on ID for the same document (such asarticle/123.html), and also specify another template in the background "Document Template" field (such ascustom/special-article.htmlWhich one will AnQi CMS use first?A: The template loading logic of Anqi CMS usually prioritizes clearer, more specific settings. In this case, the manually specified template in the background "Document Template" field (custom/special-article.htmlThe priority of templates recognized based on ID will be higher than those automatically identified based on IDarticle/123.htmlThis means that if you specify it in the background,

Related articles

How to view or modify the access URL of the mobile site in the AnQiCMS backend settings?

As an experienced website operations expert, I am happy to provide a detailed explanation of how to easily manage the access URL of the mobile site on the AnQiCMS backend, ensuring that your website provides a smooth and optimized access experience on different devices. --- ## SecureCMS: Easily manage mobile website URLs and optimize user access experience In today's era where mobile devices have become the mainstream access terminal, a clear, memorable, and search engine optimized mobile website URL is crucial.AnQiCMS knows this and provides an intuitive and convenient backend setting

2025-11-06

When developing locally in the Windows environment, after running the AnQiCMS executable file (`anqicms.exe`), in which path will the data file be generated?

As an expert who has been deeply involved in website operations for many years, I am well aware that clearly understanding the storage location of data files in the local development environment is crucial for development efficiency and troubleshooting.AnQiCMS (AnQiCMS) is a lightweight content management system developed based on the Go language, and its ease of deployment is one of its major advantages.Where is the data file generated by running the executable `anqicms.exe` in the local Windows environment?Let us delve deeper together. Straightforwardly speaking

2025-11-06

Are the generation paths of the `robots.txt` and `sitemap.xml` files fixed on the server?

As an experienced website operation expert, I fully understand the core status of these two files, `robots.txt` and `sitemap.xml`, in website SEO optimization.They are like the 'diplomats' that communicate between websites and search engines, whose norms and accuracy directly affect the crawling and inclusion of website content.Today, let's delve deeply into the generation and management mechanism of these two files in AnQiCMS (AnQiCMS), especially the path issues on the server.### Search Engine "Traffic Rules": `robots

2025-11-06

What is the path of the initialization installation page displayed when AnQiCMS is installed and accessed for the first time?

As an experienced website operations expert, I know how crucial the initial installation experience of a content management system is for users.AnQiCMS (AnQi CMS) has won the favor of many users with its high performance brought by the Go language development and many enterprise-level features.However, after the system deployment is completed and the browser is opened for the first time to access, many new users may wonder where the 'initial installation page' is located?This question feels a bit confused.

2025-11-06

How to determine the current template directory name so that it can be dynamically referenced in the template to access static resource paths?

Certainly, as an experienced website operation expert, I am happy to deeply analyze the strategy and practice of dynamically referencing static resource paths in Anqi CMS. --- ## The Beauty of Dynamics, the Art of Operations: How to Flexibly Refer to Static Resource Paths in AnQi CMS One of the core values of a content management system in website operations is to provide high flexibility and maintainability.How to efficiently and dynamically manage the paths of static resources (such as CSS, JavaScript, images, etc.) during template design and theme switching is an important indicator of a CMS's usability

2025-11-06

Where is the `{API Key}.txt` file created under the `public` directory mentioned in `help-plugin-push.md`?

As an experienced website operations expert, I fully understand the importance of Search Engine Optimization (SEO) for website traffic and exposure.Among the many powerful functions of AnQiCMS (AnQi Content Management System), the link push tool is undoubtedly a tool to accelerate the inclusion of website content and improve search engine friendliness.Today, let's delve deeply into a seemingly minor but crucial detail in Bing Search Engine's proactive push - where is that `{API Key}.txt` file created under the `public` directory?

2025-11-06

How to dynamically obtain the base URL address of the website in the template (`BaseUrl`)?

As an experienced website operations expert, I have accumulated rich experience in the practice and application of content management systems (CMS), especially with the powerful functions and flexible features of AnQiCMS (AnQiCMS).Today, we will delve into a crucial issue in template development: how to dynamically obtain the base URL of a website (`BaseUrl`) and apply it to real-world scenarios.Dynamically retrieve `BaseUrl`: The Foundation of Website Flexibility In website operations

2025-11-06

Why does the URL address of my image not change after replacement, but how can I check if the actual image file has been updated?

As an experienced website operation expert, I know that the efficiency and accuracy of content updates are crucial in daily work.Especially visual elements such as images are often the core of a website's ability to attract users and convey information.When we replaced an image in the Anqi CMS backend, we found that the URL address on the front page was still the old one. This 'URL unchanged' phenomenon can indeed be confusing and even make one doubt whether the update has really taken effect.

2025-11-06