In the flexible and powerful template system of AnQiCMS, building website navigation is one of the fundamental tasks of content operation. We often encounter two similar but distinct tags:categoryListandnavListAs an experienced website operations expert, I am well aware of how to skillfully use these tools according to the specific needs of the website to achieve **user experience and content management efficiency.Today, let's delve deeper into the situation where we should prioritizecategoryListinstead ofnavListBuild website navigation.


Understand the navigation construction cornerstone in AnQiCMS.

First, let's briefly reviewcategoryListandnavListThe core functions of these tags.

navListTags: Flexible global navigation tool.

navListIt is used to build a website navigation list as the name implies. Its data source is directly from the "Website Navigation Settings" module of the AnQiCMS backend.You can create multiple sets of navigation here, and add custom links to each set of navigation, which can be internal pages, article/product model homepages, specific category pages, or even external links.navListSupports up to two levels of navigation structure, which is very suitable for building the main menu, footer menu, or universal sidebar menu of a website. Its advantages lie in:

  • Highly customizable:You can freely define the display name of the navigation item, the link address, and even add subtitles and descriptions.
  • Highly flexible: Can easily integrate various links, including links to external websites, or standalone single-page links (such as "About Us", "Contact Us").
  • Structure is stable:The navigation hierarchy and content are manually configured on the backend, not directly affected by the amount of content published, and are suitable as the core, relatively fixed guide entry of the website.

categoryListLabel: Dynamic Guide to Content Structure Deep Dive

categoryListThe tag is designed around the content model and classification system of AnQiCMS.Its data is directly extracted from the "article model", "product model", or other custom model categories you create.categoryListCan dynamically list all child categories under a specified model and parent category, even obtain all site categories. Its core advantage lies in:

  • Content-driven dynamics:When you add or adjust categories in the background,categoryListthe navigation structure will be updated automatically, without the need to manually modify the template code. This is particularly important for websites with frequent content updates.
  • Deep content exploration:Easily implement multi-level nested category navigation, guiding users to delve deeper into various content themes on the website.
  • Closely integrated with content information:In addition to category names and links,categoryListCan directly provide category descriptions, thumbnails, document counts, and more, making navigation more than just links, but also a part of content preview.
  • SEO friendly:The website's classification structure is clearly mapped to the navigation, which helps search engines better understand the organization of the website's content, improving inclusion and ranking.

When should it be prioritized.categoryListWhat are the core considerations?

Once you understand their characteristics, the right time will come naturally. You should prioritize usingcategoryListto build navigation, mainly including the following core scenarios:

  1. When the core purpose of navigation is to present the content classification system of the website.

    • Typical scenario:Blog site article categories, e-commerce product categories, news portal channel categories, technical document website chapter directories, and so on.
    • Reason:The main demand of users of this website is to browse content by category.categoryListIt directly reflects the organization of the content, can present these categories most intuitively and dynamically, allowing users to quickly find topics of interest. For example, a food blog sidebar may need to display categories such as 'home-cooked dishes', 'baking', 'Western cuisine', and these categories may continue to be subdivided, at this timecategoryListBy simpleforLoop nesting can be perfectly implemented.
  2. When the navigation structure of the website needs to automatically adjust with the content update.

    • Typical scenario:Add new product lines, release new content topics, adjust category levels, and other operations, all hope that the navigation can synchronize in real time.
    • Reason: categoryListIs dynamic, when you manage categories in the background, the navigation will automatically update, greatly reducing the workload of manual maintenance by operation personnel, and avoiding information lag or errors. If usingnavListEach time the classification changes, it needs to be manually modified in the navigation settings, which is inefficient and prone to errors.
  3. When you need to use the additional information of the classification to enrich the navigation display.

    • Typical scenario:Display category thumbnails, brief descriptions, or the number of articles/products under the category in the navigation.
    • Reason: categoryListofitemThe object provides rich classification fields such asThumb/Description/ArchiveCount), you can directly call these data in the template to make navigation more vivid and informative.For example, on the product list page, the side navigation shows how many products are in each category next to the category, which can effectively guide users to click.
  4. When you need to build a model-specific navigation.

    • Typical scenario:The website has both articles and products, you need a navigation that only displays the "products" category, or a navigation that only displays the "articles" category.
    • Reason: categoryListCan pass throughmoduleIdThe parameter precisely specifies which content model's category to retrieve, allowing you to create dedicated navigation areas for different content types, without interference, and with clear logic.

Summarizing: The core principle of choice

In a nutshell, choicecategoryListOrnavListThe core principle lies in:What are the 'data source' and 'main service object' of navigation?

  • If your navigation mainly comes from the preset, relatively fixed link collection in the background, and may include external or non-content categorized pages, thennavListis your first choice.It is more like a carefully planned guide chart designed by humans.
  • If your navigation mainly comes from the content classification structure of the website and needs to be dynamically updated, and the purpose is to guide users to explore the content in depth, thencategoryListit is a more efficient and intelligent choice.It is more like a dynamic catalog that grows from the content itself.

In practice, the two are not completely independent. Usually, a complex website will use both tags. For example, you can usenavListBuild the top navigation of the website (including common links such as 'Home', 'About Us', 'Contact Us', as well as entry points to content aggregation pages such as 'Article Center' and 'Product Center'), and then, within the 'Article Center' or 'Product Center', use categoryListDynamically generate a detailed category sidebar or secondary navigation to achieve a deeper level of content browsing.This combination拳 ensures the stability and flexibility of the main navigation while also considering the dynamism and depth of content navigation.


Frequently Asked Questions (FAQ)

1.navListCan the content categories be displayed?Of course you can.navListSupport selecting "Category Page Link" as a navigation item. However, this method requires you to manually select each category and maintain its hierarchical relationship in the background "Website Navigation Settings".When the number of categories is large or changes frequently, the maintenance cost is high, and it is not as good ascategoryListIt is convenient to generate dynamically.

2.categoryListCan external links or standalone page links be added directly?It cannot be implemented directly.categoryListThe data source is strictly bound to the AnQiCMS content classification system. It cannot be likenavListConfigure external links or single-page links directly. If you need to mix these types of links in the content category navigation, you may need tocategoryListGenerated category link as a part, then throughnavListOr manually write HTML to add other types of links, or consider creating these "independent" pages as a single-page document type under a specific category.

3. How to include a dynamic article category dropdown menu in the main navigation (usingnavListconstruction)?This is a common mixed use scenario. You cannavListCreate a top-level navigation item named "Article Center" or "Blog" with a link to the home page of the article model. Then, in the dropdown menu or sub-menu area of the navigation item, proceed throughcategoryListTags dynamically list all top-level categories or popular categories under the article model.This allows users to quickly locate the article area through the main navigation and also to browse more finely through the dynamically generated category menu.