For users of AnQiCMS, understanding the organization of template files is the key to efficiently manage the display of website content.A clear and organized template directory structure, not only can it help you easily customize the appearance of the website, but it can also greatly enhance the flexibility and efficiency of content operations.

Anqi CMS template files are unified in use.htmlAs a suffix, and placed centrally in the root directory of the website/templateIn the folder. And all the static resources such as stylesheets, JavaScript scripts, and images used in all the templates have their own home:/public/static/Catalog. Such a 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:config.json

In/templateUnder the directory, each independent template needs to have its own exclusive directory. In this directory, there is a very important file -config.json. It is like the 'ID card' of this template, containing basic information such as the name, version, description, and author of the template. Among them,template_typeThe field is particularly worth paying attention to, as it determines which adaptation mode your website will adopt:0represents adaptive mode,1It is the code adaptation mode, while2This 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 respond.

The core organization mode: classified template files

AnQi CMS provides two template organization modes: folder organization mode and flattened file organization mode. We usually recommend usingFolder organization modeBecause it has a clearer structure, it is also easier to manage, especially suitable for rich content and diverse enterprise websites.

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

    • bash.htmlThis is a good place to put the website header (header), footer (footer), and other common parts.Through the inheritance mechanism of the template, all pages can refer to it, avoiding redundant writing.
    • partial/The catalog: it usually stores reusable code snippets, such as sidebars, breadcrumb navigation, contact forms, etc.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 templateThe core value of Anqi CMS lies in its flexible content management capabilities, which are fully demonstrated in template organization. It encourages you to create exclusive templates for different types of content:

    • Home page:index/index.htmlIs the facade of your website, deciding the impression of visitors on their first visit.
    • Content model home page: If you have created different content models such as articles, products, etc., 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 list pages for specific categories, such asarticle/list-10.htmlCan be used specifically for the article category list with ID 10, allowing different themed list pages to present unique styles.
    • Document detail page:{模型table}/detail.htmlIt is a regular document detail page. Similarly, you can also create a dedicated template for a specific document, for examplearticle/detail-123.htmlThis is the article detail for ID 123. Such fine-grained control is very useful for special event pages or key product displays.
    • a single page detail page: Pages like "About Us", "Contact Us", and others are used by defaultpage/detail.html. If you want the "About Us" page to have a unique layout, you can specify it in the background.page/about.htmlAs long as you create this file in the template directory.
  3. Special function pageIn addition to the pages driven by the above content, AnQi CMS also reserves many template locations for special feature 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. Adapt for mobile:mobile/SubdirectoryWhen your template type is selected as "Code Adaptation" or "PC+Mobile"mobile/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.htmlThat is the corresponding file on the mobile endmobile/article/detail.html.

Flexible use and customization of template potential

The template organization method of Anqi CMS gives you great 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 uses in the background.This means you can create a specific download page according to your business needsdownload.htmlTemplate, or design a special page for a festival activityevent.htmlTemplates, without the need to modify the general template, can achieve highly personalized content display.

The AnQi CMS template engine syntax is similar to Django, variables are enclosed in double curly braces{{变量}}Representation, conditional judgment, and loop control use single curly braces and the percentage sign.{% 标签 %}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?

Invest time and effort to organize the template directory structure well, it will bring many benefits to your website operation:

  • Clear and maintainableWhen a website has more features and richer content, a well-organized directory structure allows you or your team members to quickly find and understand the corresponding template files for specific pages, greatly reducing maintenance costs.
  • Efficient reuse: Passbash.html/partial/And the template inheritance mechanism, you can reuse code to the maximum extent, reduce redundancy, and improve development efficiency.
  • Flexible customizationWhether it is to customize the style for specific content or adjust the layout of a page, this modular organization method can help you easily achieve it without affecting the stable operation of other parts of the website.
  • Team collaborationA conventional directory structure that can help team members quickly adapt to the project, work together, reduce communication costs and potential errors.

In summary, the template directory structure design of Anqi CMS aims to provide you with a powerful and flexible content management solution.Master and effectively use these organization principles, and you can easily control the content display of the website, making each content release accurate and efficient.


Frequently Asked Questions (FAQ)

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 a specificCategoryAt the time, you can find the "Category Template" option in the "Other Parameters", directly enter the filename of the template you want to use, for exampledownload-list.htmlSimilarly, when editing the specificDocumentorsingle pageAlso, there will be fields such as "Document Template" or "Single Page Template", where you can enterdownload-detail.htmlorabout-us.htmlCustom template filenames. The system will prioritize using these specified template files to render the page.

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

Even if your website pursues a unified style, we strongly recommend that you follow the directory structure recommended by Anqicms. The main benefit of doing so is to improvemaintainabilityandextensibilityFor example, you can place most common styles and layouts inbash.html/{模型table}/list.htmland{模型table}/detail.htmlIf 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.Code reuse in common parts can also make your website more efficient and easy to manage.

3. The mobile template'smobile/Do the directory structure and the main template directory structure have to be consistent?

mobile/The internal structure of the directory is原则上Keep consistent with the main template directoryThis means that if you have one on your PC end,article/detail.html, the corresponding mobile template should be `mobile/article/detail.html