How to organize directory structure of AnQi CMS template files to manage content display?

Calendar 👁️ 62

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

Related articles

How to configure Anqi CMS to support adaptive, code adaptation, or PC+Mobile independent site display mode?

In the current internet environment, it has become a norm for users to browse websites on various devices. How to ensure that your website presents a**good effect on different devices is one of the keys to the success of website operation.AnQiCMS (AnQiCMS) is well-versed in this, providing flexible and diverse display mode configurations, allowing you to easily switch between adaptive websites, code adaptation, or PC+Mobile independent sites according to your actual needs.This article will detail how to configure these display modes in Anqi CMS, ensuring that your content shines on any screen.###

2025-11-07

What template engine syntax does AnQi CMS support to control content display?

As users of AnQi CMS, we all hope to efficiently and flexibly control the way website content is presented.AnQi CMS performs very well in this aspect, it provides a set of intuitive and powerful template engine syntax, allowing us to easily achieve a variety of content display needs. ### Basic: Anqi CMS Template Engine: Django style, easy to learn and use Anqi CMS template engine adopts a marking method similar to Django syntax, which allows friends with experience in other template engines to quickly get started.Its design philosophy is to strive for simplicity and efficiency

2025-11-07

How does AnQi CMS ensure the compliance and security of displayed content?

In website operation, the compliance and security of content is a focus for every webmaster and operator.It not only concerns the reputation and trust of the website, but may also touch upon the legal and regulatory line.As a system dedicated to providing users with an efficient and secure content management experience, AnQiCMS (AnQiCMS) integrated these core demands into its security mechanism from the outset, ensuring the compliance and security of the content we display in multiple dimensions.<h3>Build a Secure Foundation: From System Bottom to Content Interaction</h3> The security of AnQi CMS primarily originates from its solid technical foundation

2025-11-07

How do static caching and SEO optimization enhance the loading speed and visibility of website content?

In today's digital age, whether a website can stand out among numerous competitors, attract and retain users, loading speed and search engine visibility (SEO) are two crucial factors.No one wants to wait for a website that does not respond promptly, and if the content of your website is difficult to be found by search engines, then the best content is of no value.Luckyly, AnQiCMS (AnQiCMS) with its unique architecture and rich features, can effectively help websites achieve double improvement in speed and visibility.

2025-11-07

How to define and use variables in AnQiCMS templates to display dynamic content?

When building a website, we all hope that the content can change flexibly according to different pages and different data, rather than unchanging static text.AnQiCMS leverages its high-performance architecture based on the Go language and a flexible Django-like template engine, providing us with powerful dynamic content display capabilities.And at the core of all this, it cannot be separated from the definition and use of 'variables'. Mastering how to define and use variables in the AnQiCMS template is like mastering the key to activating the dynamic vitality of the website.This is not just a technical operation, but also the realization of content marketing and SEO

2025-11-07

How to flexibly control the display logic of conditional judgment and loop control tags?

Build dynamic and interactive websites in AnQi CMS, it is inseparable from precise control of the content display logic.This involves conditional judgment (`if`) and loop control (`for`) tags playing a core role.They are like a powerful 'combination punch', making the template no longer a static layout, but one that can intelligently respond and flexibly present content based on data changes.The template syntax of AnQi CMS borrows from the Django template engine, its concise and efficient marking method allows even beginners in template development to quickly get started.

2025-11-07

How can you customize templates for specific documents or categories to achieve personalized display?

In Anqi CMS, when you want a specific article, product, category, or standalone page to have a unique display effect, the system provides a flexible template customization feature that allows you to easily achieve personalized content display.This is greatly beneficial for creating brand characteristics, launching special event pages, optimizing the user experience of specific content, and even improving SEO performance.Why do we need to customize templates for specific content?Imagine that on your website there is an "About Us" page about the history of the company, you may want it to be dignified and elegant

2025-11-07

How does Anqi CMS automatically extract the first image of the document content as a thumbnail for display?

In website content operation, carefully selecting and setting thumbnails for each article or product page is a time-consuming and important task.A captivating thumbnail can significantly increase click-through rate, optimize user experience, and benefit SEO performance.However, facing an overwhelming amount of content, manually uploading and adjusting thumbnails will undoubtedly become a huge burden.AnQi CMS deeply understands this, and for this reason, it provides a smart and flexible solution that automatically converts the first image of the document content into a thumbnail, greatly simplifying the operation process.## Smart Extraction

2025-11-07