When operating multiple websites, it is crucial to maintain a unique style and presentation for each site, which not only helps in brand building but also better meets the needs of different audiences.AnQiCMS provides strong support for multi-site management, one of its core strengths being the ability to flexibly set independent templates for each site, making content display more personalized.

AnQiCMS multi-site capability and template basics

AnQiCMS is a content management system developed based on the Go language, and its multi-site management feature is one of the highlights tailored for small and medium-sized enterprises and content operation teams.It allows you to manage multiple brands, sub-sites, or content branches simultaneously, greatly reducing repetitive work.In order for these sites to have unique characteristics in content display, their flexible template engine is the key.

AnQiCMS template system uses a syntax similar to Django template engine, using.htmlAs a template file suffix. All template files are stored in/templateUnder the directory, each independent template package has its own exclusive folder under this directory.This means that as long as you specify a different template package for each site, you can easily achieve visual and layout differentiation.

Specify a set of independent templates for your new site

When you create a new site through the AnQiCMS backend, the system will provide a very intuitive option to select the template that the site will use.In the 'Multi-site Management' feature, after clicking 'Add New Site', you will see a dropdown menu to 'Select the Template to Use'./templatea subfolder under the directory.

For example, if you have a main site and a special site, you can/templatecreate two folders under the directory, such asmain_themeandspecial_topic_themePut different template files in it. When you add the main site, selectmain_themeSelect when adding a special topic sitespecial_topic_themeThey can instantly have a completely different appearance and layout. This is the first and most important step in achieving personalized site display.

Deep customization: template strategy for different levels of content

AnQiCMS's template flexibility is not just about this, it also provides a multi-level content template coverage mechanism, allowing you to finely control the display of content according to your actual needs.

FirstlySite-level general templateEach template package includes some conventional basic template files such asindex.htmlUsed for the homepage,errors/404.htmlUsed for the 404 error page,guestbook/index.htmlUsed for message pages, etc. These are the default general styles of the site. The system will use these general templates first when no specific template is specified for the content.

Next isContent model level template.AnQiCMS supports custom content models (such as article models, product models, etc.), each model can have its own default detail page and list page templates.article/detail.htmlandarticle/list.html, create for product modelproduct/detail.htmlandproduct/list.htmlThis means that all content belonging to the "Article" model will default to using the template under the Article model, and the content of the "Product" model will use the template under the Product model.

Further, you can also proceedCategorization templatethe settings.In the background 'Document Classification' management page, when editing a category, you can find the 'Category Template' option.download_list.htmlUsed to display the content list under the category. The system even allows you to choose whether to apply it to the subcategory, so that the settings of the template can be automatically inherited to the lower-level categories, which is very convenient.

Finally, it isTemplate for detailed page of specific content (document/product/singleton page).This is the finest grain of control.When you edit a specific article, product, or single page, there will be a field for "Document Template" or "Single Page Template" in the "Other Parameters".about_us.html), allowing this content to be displayed using a completely independent template, unrestricted by the model or category it belongs to.

It is very important to understand these hierarchical relationships: the highest priority is given to the specific content detail page template, followed by the category-level template, then the content model-level template, and the lowest priority is the site-level general template.This design allows you to flexibly meet various content display needs, from the macro style of the site to the micro layout of a single article, you can achieve precise control.

Template file organization and coding standards

To ensure that the template can be correctly identified and used by AnQiCMS, it is necessary to follow some file organization and coding standards:

  • Template root directory: All template packages are placed in/templatedirectory.
  • template package structure: Each template package is an independent folder, for example/template/defaultor/template/my_custom_theme.
  • configuration file: Each template package must have one insideconfig.jsonFile, used to describe the template name, version, author, and other information.
  • Static resources: Recommend placing the CSS, JavaScript, images, and other static resources used in the template./public/static/In the corresponding template folder under the directory, for example/public/static/my_custom_theme/css/style.css.
  • Mobile end templateIf your website needs a separate mobile template, you can create one in the template package foldermobile/Subdirectory, and place the mobile-specific template files in it according to the same structure as the PC template.
  • EncodingAll template files should use UTF-8 encoding to avoid garbled characters.
  • SyntaxTemplate files use syntax tags similar to Django, such as{{变量}}Used for output variables,{% 标签 %}Used for logical control.

By reasonably planning template files and flexibly configuring in the background, you will be able to fully utilize the powerful capabilities of AnQiCMS in multi-site management and content display, creating a unique user experience for each website.


Frequently Asked Questions (FAQ)

How do I create a new template package for my multi-site?

To create a new template package, you need to be on the AnQiCMS server's/templateCreate a new folder under the directory, for examplemy_new_theme. Within this new folder, you need to create at least oneconfig.jsonFile used to describe the basic information of this template package, such as name, version, etc. After configuration, when you create a new site or edit the global settings of an existing site in the AnQiCMS background, you will be able to see and select the template you