How to build a multi-level navigation menu in AnQiCMS to optimize the display of the website structure?

Calendar 👁️ 59

The website's navigation system, like a city map, guides visitors to explore every corner of your website. A clear and intuitive multi-level navigation can greatly enhance user experience and is an indispensable part of Search Engine Optimization (SEO), helping search engines better understand the structure of the website and thus improve content inclusion and ranking.In AnQiCMS, building a set of efficient and beautiful multi-level navigation menus is actually simpler than you imagine. It provides flexible backend configuration and powerful template tags, allowing you to easily implement it.

Build the navigation foundation: start from the background configuration

Build multi-level navigation in AnQiCMS, we first need to go to the "background settings" area of the backend, find the "navigation settings" feature.This is the command center of all your navigation menus.

1. Navigation category management: Define menu location

In the "Navigation Settings", you will find a "Default Navigation" category.This is usually used for the top navigation bar of a website. But your website may also need different menu layouts in the footer, sidebar, and even on mobile.AnQiCMS very considerately allows you to create multiple navigation categories, such as you can add a category named "footer navigation" or a category named "mobile menu".The benefit of doing this is that you can customize exclusive navigation content for different locations and scenarios, without interference, and it is also easier to manage.

2. Navigation link settings: Fill menu content

After defining the navigation categories, the next step is to fill in specific links for these categories.The navigation link settings of AnQiCMS support up to two levels of navigation, which means you can implement a primary menu and a first-level dropdown submenu structure.

When adding a new navigation link, you will see the following key settings:

  • Parent navigation:This is the core of implementing multi-level navigation. If you want to create a main menu item, select 'Top-level navigation';If you want it to become a submenu of a main menu item, just select the corresponding parent menu item from the dropdown list.
  • Display name:This is the text displayed on the front page navigation. You can set it flexibly and it does not necessarily have to be consistent with the page title linked to, in order to be more concise or more attractive.
  • Subtitle name and navigation description:If your design requires, you can add a subtitle or a brief description to the navigation items, which can be used to enrich the display information of some featured templates.
  • Link Type:AnQiCMS provides three flexible link types to meet various content organization needs:
    • Built-in links:Used for the website homepage, article model homepage, product model homepage, and other custom model homepages. After selection, the system will automatically fill in the corresponding links.
    • Category page links:This is a convenient way to directly use the categories (such as "Company News", "Product Categories") or single pages (such as "About Us", "Contact Us") you create in AnQiCMS as navigation items.You just need to choose from the list.
    • External links:When you need to link to a specific URL within the site or an external website (such as a partner's official website, social media homepage), you can select this option and manually enter the complete URL address.
  • Display order:You can control the order of navigation items by setting numbers, the smaller the number, the closer the navigation item is to the front of the list.Currently, AnQiCMS uses numerical sorting, and in the future, it will also support drag-and-drop sorting to further improve the convenience of operation.

By following these steps, you can build a clear multi-level navigation menu system in the AnQiCMS backend.

Template call: Let the navigation appear on the website.

The background configuration is complete, and the next step is how to display these carefully designed navigation menus on the website front-end. The AnQiCMS template system uses syntax similar to the Django template engine, bynavListLabel, you can very conveniently call out the navigation data configured on the back-end.

1. UnderstandingnavListTag

navListThe tag is the key to calling navigation data in the AnQiCMS template. Its basic usage is{% navList navs %}{% endnavList %}of whichnavsThe variable name you define for the navigation list. You can customize it according to your preference.

If you want to call the menu under a specific "navigation category", such as the "footer navigation" created earlier, you can do so bytypeIdto specify the parameters:{% navList footerNavs with typeId=2 %}{% endnavList %}(Here, thetypeId=2Assuming the "footer navigation" ID is 2 in the background, you can view it in the navigation category management in the background).

navsThe variable is an array object, you need to useforLoop to traverse each navigation item (item)。EachitemincludesTitle(Display name),Link(link address),IsCurrent(whether it is a link to the current page) and other fields. Most importantly, if a navigation item contains a sub-menu, itsNavListThe field will also be an array, and it can be achieved through nested structuresforto iterate in a loop.

2. Nested structure to implement multi-level navigation

To implement the display of two-level navigation, you need to use the nested list structure of HTML and combinenavListlabel'sNavListthe subfield to loop:

<nav>
    <ul class="main-nav">
        {% navList navs with typeId=1 %} {# 假设1是主导航的typeId #}
            {% for item in navs %}
                <li class="{% if item.IsCurrent %}active{% endif %}">
                    <a href="{{ item.Link }}">{{ item.Title }}</a>
                    {% if item.NavList %} {# 判断是否有子菜单 #}
                        <ul class="sub-nav">
                            {% for subItem in item.NavList %}
                                <li class="{% if subItem.IsCurrent %}active{% endif %}">
                                    <a href="{{ subItem.Link }}">{{ subItem.Title }}</a>
                                </li>
                            {% endfor %}
                        </ul>
                    {% endif %}
                </li>
            {% endfor %}
        {% endnavList %}
    </ul>
</nav>

In this code, the outermostulrepresents the first-level menu, the innerulIt will pass.item.NavListto implement the second-level dropdown menu.IsCurrentThe field can help you add links to the current page you are visitingactiveThe class name can be used to highlight and further optimize the user experience

3. Dynamic content combined with navigation

AnQiCMS template tags have very high flexibility, you can even display links in the second-level navigation, as well as dynamically display the list of articles under the category or even deeper subcategories.This can bring richer interaction and information display to your website.

For example, under a second-level menu of a product category, you may want to directly display several popular products under that category:

`html

Related articles

How to dynamically generate and display the page's SEO title, keywords, and description (TDK)?

Search engine optimization (SEO) is a key factor for the success of a website, and the page title (Title), keywords (Keywords), and description (Description), which we often call TDK, are also the core elements for search engines to understand and display your web content.They not only affect the willingness of users to click on search results, but also directly relate to the ranking performance of the website in search engines.AnQiCMS is a corporate-level content management system that has fully considered SEO friendliness from the outset

2025-11-08

How to correctly obtain and display contact information in the template?

In website operation, clearly and effectively displaying contact information is crucial for user experience and business conversion.AnQiCMS (AnQiCMS) provides us with flexible and powerful features, allowing us to easily retrieve and display these key information in templates. --- ### **Backend Configuration: Source of Contact Information** All website contact information is centralized in the backend for unified management in AnQi CMS.This means that whether you need to modify the contact phone number, email, or add new social media links, you do not need to touch any code, just perform simple operations in the background

2025-11-08

How to accurately call the system settings (such as website name, Logo) in the template for display?

As AnQi CMS users, we often need to ensure that the core information of the website, such as the website name, Logo, filing number, etc., is displayed accurately and correctly on all pages of the website.This concerns the unity of brand image, and it directly affects user experience and search engine optimization.AnQi CMS with its efficient architecture based on the Go language and template engine syntax similar to Django, makes the invocation of these basic information intuitive and flexible.Next, let's explore how to easily call and display these important system settings in the Anqi CMS template.Useful ###

2025-11-08

What flexibility does the Django template engine syntax provide in content display?

AnQi CMS as an efficient and flexible content management system, its flexibility in content display is largely due to its support for Django template engine syntax.For us content operators and website administrators, this means we do not need to deeply learn complex programming languages, but can freely organize and present website content as if we were building with blocks.Then, what flexibility does the Django template engine syntax bring to our content display?### One, direct and efficient data call and display First

2025-11-08

How can the breadcrumb navigation of the current position be displayed on the page?

In website navigation, Breadcrumb navigation is a very practical auxiliary tool.It clearly shows the user's current position on the website, provides a convenient return path, thereby significantly improving the user experience, and also has a positive effect on search engine optimization (SEO), helping search engines understand the structural hierarchy of the website.AnQiCMS has fully considered this point and provided a simple and powerful way to display breadcrumb navigation on the page.With built-in template tags, even without complex programming knowledge, this feature can be easily implemented.###

2025-11-08

How to display category lists on the homepage or category pages?

In Anqi CMS, managing and displaying the category list is the core of website content organization.It is crucial to clearly display the classification structure for optimizing user navigation experience or improving search engine crawling efficiency.The Anqi CMS provides concise and powerful template tags, allowing you to easily display your content categories on the homepage, category pages, or any place you need.### Understanding Core: `categoryList` Tag In the AnQiCMS template system, the main tag used to retrieve the category list is `categoryList`

2025-11-08

How to retrieve and display detailed information for a specific category, such as the category logo and introduction?

In website operation, a clear and informative classification display is the key to attracting visitors, improving user experience, and optimizing search engine rankings.AnQiCMS provides a user-friendly and powerful template tag system that allows you to flexibly obtain and display detailed information of various categories on your website, such as category logo and introduction, thereby creating a more attractive content layout. ### Understand Category Information Management and Configuration Category information management is very convenient in the Anqi CMS backend.When you enter the 'Content Management' under 'Document Category' to add or edit

2025-11-08

How to list and display the titles and links of all single pages?

AnQi CMS provides a user-friendly and powerful content management system, where the single-page feature is an ideal choice for building independent pages such as "About Us", "Contact Information", or "Privacy Policy".When you need to display the titles and links of these single-page in a centralized position on the website, such as in the footer navigation, sidebar, or a dedicated page index, the template tags of AnQiCMS can help you easily achieve this.In the AnQiCMS backend, single-page content is created and maintained under "Page Resources" > "Page Management".You can easily add to the website like 'About Us'

2025-11-08