For users of AnQiCMS, understanding the organization of template files is the key to efficient management of website content display.A clear and organized template directory structure, which not only allows you to easily customize the appearance of the website, but also greatly enhances the flexibility and efficiency of content operation.

The template files of Anqi CMS are used uniformly.htmlAs a suffix, and stored in the root directory of the website/templateThe folder contains. And all the static resources such as style sheets, JavaScript scripts, and images used in all templates have their own home:/public/static/Catalog. This separation design allows you to focus more on the template itself when adjusting the website layout and style, without worrying about confusing resource files.

The 'identity recognition' of each template set:config.json

In/templateUnder the directory, each independent template needs to have its own dedicated directory. This directory contains a very important file.config.jsonIt is like the 'ID card' of this template, containing basic information such as the name, version, description, and author of the template.template_typeThe field is particularly worth paying attention to, as it determines which adaptation mode your website will adopt:0represents the adaptive mode,1is the code adaptation mode,2It is an independent mode for PC and mobile devices.This means that whether your goal is to build a responsive website compatible with all devices or to provide a customized experience for different devices, AnQi CMS can flexibly handle it.

the core organization mode: categorized template files

The CMS provides two template organization modes: folder organization mode and flat file organization mode. We usually recommend usingFolder organization modeIt is clearer in structure and more convenient to manage, especially suitable for enterprises with rich content and diverse functions.

  1. A collection of public code and code snippetsIn the template directory, you will find some files and directories specifically used to store public code and code snippets:

    • bash.html: This is a good place to put the header, footer, and other common parts of the website page.Through the inheritance mechanism of the template, all pages can refer to it, avoiding the need to rewrite it.
    • partial/Directory: This is usually where reusable code snippets are stored, such as sidebars, breadcrumb navigation, contact forms, and so on.When you need to display the same element on multiple pages, you only need to write it once here and then introduce it where needed.
  2. Content type-specific templatesThe core value of AnQi CMS lies in its flexible content management capabilities, which are fully demonstrated in template organization. It encourages you to create dedicated templates for different types of content:

    • Home page of the website:index/index.htmlIs the facade of your website, deciding the impression of visitors on their first visit.
    • Content model home pageIf you create articles, products, and other different content models, you can create individual homepages for each model, for examplearticle/index.htmlUsed for the article model homepage,product/index.htmlUsed for the product model homepage.
    • Document List Page: The general list page is usually{模型table}/list.html. But the strength of Anqi CMS lies in the fact that you can even customize the list page for specific categories, such asarticle/list-10.htmlCan be specifically used for the article category list of ID 10, allowing different themed list pages to present unique styles.
    • Document details page:{模型table}/detail.htmlis a regular document details page. Similarly, you can also create a dedicated template for a specific document, such asarticle/detail-123.htmlThis is used only for the article details with ID 123. Such fine-grained control is very useful for special event pages or key product displays.
    • Single Page Detail Page:Like independent pages such as "About Uspage/detail.html. If you want the "About Us" page to have a unique layout, you can specify it in the background.page/about.htmlJust as long as you create this file in the template directory.
  3. Special feature pageIn addition to the content-driven pages mentioned above, Anqi CMS also reserves many template positions for special function pages, such as:

    • guestbook/index.html: Online message page.
    • search/index.html: Website search results page.
    • tag/index.htmlandtag/list.html:Tag cloud and tag content list page.
    • errors/404.htmlanderrors/500.html:Used to handle page not found and internal server errors.
    • errors/close.html:The page displayed to visitors when the website is closed.
  4. Responsive design: mobile/SubdirectoryWhen your template type is selected as "Code Adaptation" or "PC+Mobile", you can create amobile/The subdirectory. The internal structure of this directory is consistent with the main template directory, used to store template files specifically designed for mobile devices. For example, if your PC-end article detail page isarticle/detail.htmlThen the corresponding file on the mobile end ismobile/article/detail.html.

Utilize the potential of flexible use and custom templates

The template organization of AnQi CMS gives you a great degree of freedom.For example, when creating a new article category, publishing a new document, or setting up a single page, you can directly specify the custom template file it should use in the background.download.htmlA template, or design a dedicated page for a festival activityevent.htmlTemplate, without modification of the general template, thus achieving highly personalized content display.

The template engine syntax of AnQi CMS is similar to Django, variables are enclosed in double curly braces{{变量}}Representation, conditional judgment and loop control use single curly braces and percent signs{% 标签 %}This intuitive syntax allows even beginners to quickly get started, transforming technical information into easily understandable and practical content display.

Why is it necessary to carefully organize the template directory structure?

Spending time and effort to organize a well-structured template directory will bring many benefits to your website operation:

  • Clear and maintainableWhen the website features become more numerous and the content becomes richer, a well-organized directory structure can help you or your team members quickly find and understand the corresponding template files for specific pages, greatly reducing maintenance costs.
  • Highly Efficient Reusability: Throughbash.html/partial/And with the template inheritance mechanism, you can maximize code reuse, reduce redundancy, and improve development efficiency.
  • Flexible CustomizationWhether it is to customize styles for specific content or adjust the layout of a page, this modular organization method allows you to easily achieve this without affecting the stable operation of other parts of the website.
  • Team CollaborationAn established directory structure, which can help team members quickly adapt to the project, collaborate, reduce communication costs and potential errors.

In short, the template directory structure design of Anqi CMS aims to provide you with a powerful and flexible content management solution.Master and make good use of these organizational principles, and you can easily control the display of website content, making every content release precise and efficient.


Common Questions and Answers (FAQ)

1. How to specify an independent template file for a specific category or document?

You can set it in the content management area of the Anqi CMS backend. When you edit aCategoryWhen, you can find the 'Category Template' option in 'Other Parameters', directly enter the filename of the template you want to use, for example,download-list.htmlSimilarly, in editing specific,Documentorsingle pageWhen, there may also be a "Document Template" or "Single Page Template" field, you can fill in.download-detail.htmlorabout-us.htmlAnd custom template filenames. The system will use these specified template files to render pages first.

2. If my website only needs a unified style, do I still need such a complex directory structure?

Even if your website aims for a unified style, we strongly recommend that you follow the directory structure recommended by AnQi CMS. The main benefit of doing so is to enhanceMaintainabilityandextensibility。For example, you can put most general styles and layouts in.bash.html/{模型table}/list.htmland{模型table}/detail.htmlEnglishIf the future website needs to add a special page or event, you can easily create an independent template file for it without affecting the existing structure.Public part code reuse can also make your website more efficient and easier to manage.

3. Is the structure of the mobile template template?mobile/Must the directory structure be completely consistent with the main template directory structure?

mobile/The internal structure of the directory is generallyKeep consistent with the main template directoryThis means that if your PC end has aarticle/detail.html,then the corresponding mobile template should be `mobile/article/detail.html