When should the `categoryList` tag be used instead of the `navList` tag to build website navigation?

Calendar 👁️ 56

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.

Related articles

What is the corresponding relationship between the `categoryList` tag in template development and the background "document classification" function settings?

As an experienced website operation expert, I deeply understand that the core value of a Content Management System (CMS) lies in the seamless connection between the backend configuration and the frontend display.AnQiCMS (AnQiCMS) excels in this aspect with its efficient architecture based on the Go language and flexible design.Today, let's delve deeply into the development of the Anqi CMS template and the `categoryList` tag, how it closely corresponds to the background "Document Category" function, and how we巧妙运用 this correlation to build powerful website functions.##

2025-11-06

How to add custom HTML styles or CSS classes to the category names returned by `categoryList`?

As an experienced website operations expert, I am well aware that the readability and visual aesthetics of website content are crucial for user experience, and the flexible template customization capability is the key to achieving this goal.In AnQiCMS, even for a simple category list, we have multiple ways to add personalized HTML styles or CSS classes to enhance the overall attractiveness and functionality of the website.Today, let's delve into how to assign custom styles to the category names returned by `categoryList`

2025-11-06

How to avoid performance issues when the `categoryList` tag is used with large amounts of data?

As an experienced website operations expert, I have accumulated rich experience in content management and performance optimization, especially familiar with many functions of AnQiCMS.In daily operations, we often encounter problems such as large amounts of website classification data, leading to slow page loading and increased server pressure.This is often one of the key factors affecting performance, the way the `categoryList` tag is used.

2025-11-06

How to use `categoryList` to build a flat list of all categories without hierarchy display?

As an experienced website operation expert, I know how important it is to flexibly display category lists when building website content structure.AnQiCMS (AnQiCMS) has provided us with great convenience with its powerful template tag system.Today, let's delve into a seemingly simple yet extremely practical feature: how to elegantly build a flat list of all categories using the `categoryList` tag, so that all categories are clearly displayed on your website without any hierarchy.Why do we need a flat category list?

2025-11-06

Does the `categoryList` return category link automatically adapt to the pseudo-static rule set in the background?

As an experienced website operations expert, I know the importance of URL structure for website SEO and user experience.AnQiCMS (AnQiCMS) fully considered this from the beginning, its static and SEO optimization features are one of its core highlights.Today, let's delve into a common concern of operators: When using the AnQiCMS `categoryList` tag to call category links, will these links automatically adapt to the pseudo-static rules set in the background?

2025-11-06

How to display different content in the `categoryList` loop based on the different `moduleId`?

As a senior website operations expert, I fully understand that the flexibility of content presentation is crucial for user experience and operational efficiency.AnQiCMS (AnQiCMS) relies on its powerful template engine and content model mechanism to provide us with a powerful tool for achieving this flexibility.Today, let's delve into a very practical scenario: how to intelligently display distinctive content according to different `moduleId` in the `categoryList` loop.

2025-11-06

`categoryList`Does it support filtering or displaying based on custom fields by category?

HelloAs an experienced website operations expert, I know the importance of a flexible content management system for efficient operations.AnQiCMS stands out among many CMS systems with its excellent customizability, especially in content modeling and category management, providing great convenience.However, many operators may wonder a question when using the `categoryList` tag: does it support filtering or displaying based on custom fields of categories?

2025-11-06

How to implement the display of the 'sibling categories' of the current category in `categoryList`, instead of the subcategories?

AnQi CMS is an efficient and customizable content management system, playing an important role in website operations.Its template system is powerful and flexible, allowing operators to finely control the display of content according to actual needs.Today, let's delve into a common issue in actual operation that beginners may find confusing: how to cleverly display 'sibling categories of the current category' in the `categoryList` tag, rather than its subcategories.It is of great significance to display the brother category list in terms of content organization and user experience.

2025-11-06