How to create and display multi-level navigation menus in AnQiCMS?

Calendar 👁️ 64

In website operation, a clear and effective navigation menu is the core of user experience, which can help visitors quickly find the information they need.AnQiCMS (AnQiCMS) understands this and provides flexible and powerful features for you to easily create and manage multi-level navigation menus, whether it is a simple two-level dropdown menu or a complex menu combined with dynamic content display, it can meet your needs.

Next, we will learn together how to create and display multi-level navigation menus in AnQiCMS.

1. Back-end Management: The Basics of Building Navigation Menus.

The first step to create a multi-level navigation menu is to set it up in the AnQiCMS backend management interface. Here, you can not only define menu items but also plan their hierarchical relationships.

1. Access Navigation Settings

Log in to your AnQiCMS backend, find and click on the "Backend Settings" in the left menu bar, and then select the "Navigation Settings" option.This is the center where you manage all website navigation.

2. Create Navigation Category (optional, but recommended)

AnQiCMS provides a category named 'default navigation' by default, which is usually used for the main navigation of the website.If your website needs multiple navigation areas, such as top main navigation, footer navigation, sidebar navigation, or special navigation for specific scenarios, you can create new navigation categories.

In the 'Navigation Category Management' section, click 'Add New Navigation Category', enter a meaningful name (such as 'Footer Navigation', 'Sidebar Menu'), save, and you will have an independent navigation area for easy management and future use.

3. Add navigation links: Define menu structure

This is the core step to create multi-level navigation. In the "Navigation Link Settings" area, you will see the "Add Navigation Link" button. Click it to start defining your menu items.

  • display nameThis is the text displayed on the navigation menu for users.
  • Link TypeAnQiCMS provides three flexible link types, you can choose according to your needs.
    • Built-in linkIncluding the home page of the website, the home page of the article model, the product model home page, and other system preset pages.
    • Category page linkYou can directly select the article category, product category, or single page that you have created as a navigation link to dynamically direct menu items to your content.
    • External link: If you need to link to an external website or a custom URL within the site, you can select this option and enter the full link address.
  • Parent navigation: This is the key to implementing multi-level menus.
    • To createMain MenuPlease select "Top Navigation" as the parent.
    • To createSub Menu(That is the dropdown submenu of the top-level menu), please select an existing top-level navigation from the list as its parent. Currently, AnQiCMS supports two-level navigation configuration directly in the background.
  • Display order: The order of menu items is determined by setting the size of the number, the smaller the number, the closer to the front.
  • Subtitle name and navigation descriptionThese fields provide additional text information that can be called in the template to make the navigation menu content more rich, such as adding English translations or brief introductions to menu items.

Repeat the above steps, you can add multiple first-level menus for different navigation categories, and create corresponding second-level sub-menus under these first-level menus to build a clear navigation hierarchy.

Template invocation: Display the navigation menu on the website front-end

After configuring the navigation menu on the back-end, the next step is to display these menu structures on your website's front-end.AnQiCMS uses the Django template engine syntax, through specific template tags, you can render navigation data on the page with great flexibility.

1. Find the template file

Navigation menus are usually found in the public header (header) or sidebar, footer, and other locations on a website. Depending on your template design, you may need to/templateUnder the current template folderbash.html(Public basic template) orpartial/header.htmlEdit files such as (header fragments) etc.

2. UsenavListTag navigation data call

navListIs AnQiCMS specially designed template tag for calling navigation list.

You can use the following basic structure to call navigation data:

{% navList navs with typeId=1 %}
    <ul>
        {%- for item in navs %}
            <li class="{% if item.IsCurrent %}active{% endif %}">
                <a href="{{ item.Link }}">{{item.Title}}</a>
                {%- if item.NavList %} {# 判断是否有下级导航 #}
                <dl>
                    {%- for inner in item.NavList %} {# 遍历二级导航 #}
                        <dd class="{% if inner.IsCurrent %}active{% endif %}">
                            <a href="{{ inner.Link }}">{{inner.Title}}</a>
                        </dd>
                    {% endfor %}
                </dl>
                {% endif %}
            </li>
        {% endfor %}
    </ul>
{% endnavList %}
  • {% navList navs with typeId=1 %}: This tag is used to get navigation list data.navsIs the variable name you define for the navigation list,typeId=1Represents the navigation category with ID 1 (usually the default navigation). If you have created other navigation categories, please specifytypeIdReplace with the corresponding category ID.
  • {% for item in navs %}: This will iterate through all the first-level navigation menu items.
  • item.Titleanditem.Link: Used to display the menu item name and link address.
  • {% if item.IsCurrent %}:IsCurrentIs a boolean value, it will return if the current page matches the navigation itemtrue. You can use this property to add a highlight style to the corresponding navigation item of the current page, enhancing the user experience.
  • {% if item.NavList %}This is the key to implementing multi-level navigation.NavListIt is the collection of sub-menus for the current menu item. IfNavListthere is (i.e., there are second-level menus under this first-level menu), then enter the nested loop.
  • {% for inner in item.NavList %}This loop will iterate over all second-level navigation menu items, which can also be usedinner.Title/inner.Linkandinner.IsCurrentto render.

3. Enrich your navigation menu: Combine dynamic content

Although the background directly supports two-level navigation, you can create visually richer and deeper-level menus through the flexible combination of template tags.For example, under a second-level menu item, display the latest article list or all subcategory lists associated with it.

Example: Display the latest articles under the second-level menu item

Assuming you have a top-level navigation "Products", under which there is a secondary navigation "Electronic Products", you want to display several of the latest product articles under the "Electronic Products" category when the mouse hovers over "Electronic Products".

<ul>
    {% navList navList with typeId=1 %}
    {%- for item in navList %}
    <li>
        <a href="{{ item.Link }}">{{item.Title}}</a>
        {%- if item.NavList %}
        <ul class="nav-menu-child">
            {%- for inner in item.NavList %}
            <li>
                <a href="{{ inner.Link }}">{{inner.Title}}</a>
                {% if inner.PageId > 0 %} {# 假设PageId存储了关联的分类ID #}
                    {% archiveList products with type="list" categoryId=inner.PageId limit="8" %}
                    {% if products %}
                    <ul class="nav-menu-child-child">
                        {% for product in products %}
                        <li><a href="{{product.Link}}">{{product.Title}}</a></li>
                        {% endfor %}
                    </ul>
                    {% endif %}
                    {% endarchiveList %}
                {% endif %}
            </li>
            {% endfor %}
        </ul>
        {% endif %}
    </li>
    {% endfor %}
    {% endnavList %}
</ul>

In this example, we navigate through the second-level menu items of the first-level navigation, byinner.PageIdGained the associated category ID,

Related articles

How to display 'Previous article' and 'Next article' links on the article detail page?

In website content operation, optimizing the reading experience of users has always been one of our core goals.When immersed in an excellent article, it is natural to want to smoothly switch to related or the next article without having to return to the list page to find it.This seamless navigation can not only effectively improve the user's stay time on the website, reduce the bounce rate, but also help search engines better understand the structure of the website content, thereby having a positive impact on SEO.Aqy CMS provides a very intuitive and easy-to-use solution for this

2025-11-08

How to sort the list display according to the creation time or view count of the articles?

In website content operation, the presentation sequence of content is crucial for user experience and information delivery efficiency.Whether it is a news portal, technology blog, or product showcase website, reasonably adjusting the sorting method of the content list according to different operational goals can significantly enhance the vitality and attractiveness of the website.AnQiCMS (AnQiCMS) is well-versed in this, providing intuitive and powerful features that allow us to easily sort the content list by the creation time or number of views.###

2025-11-08

How to implement the pagination display function of the article list in AnQiCMS?

The pagination feature of the article list is crucial for any content management system, as it not only improves the user browsing experience and avoids the slow loading caused by overly long single pages, but also helps search engines better crawl and index website content.In AnQiCMS, implementing this feature is both flexible and efficient, thanks to its concise template tag design. Next, we will together learn how to easily implement pagination display of article lists in AnQiCMS.

2025-11-08

How to display the viewing volume of articles or products on the frontend page?

Bring content to life: easily display the number of views for articles or products on the Anqi CMS front-end page In website operations, the number of views for articles or products is often an important indicator of how popular the content is.It not only provides visitors with an intuitive reference, forming a "social identity" effect, guiding them to discover popular content, but also helps operators quickly identify high-value content.AnQi CMS is an efficient content management system that fully considers the actual needs of users, making it very simple and intuitive to display the number of views of articles or products on the front-end page.

2025-11-08

How to highlight the link of the current visited page in the navigation menu?

When a user visits your website, a clear and intuitive navigation menu can significantly enhance their browsing experience.One important optimization is to make the navigation menu intelligently highlight the current page link being visited, so that visitors can clearly know where they are on the website.AnQi CMS provides a simple and powerful way to implement this feature, without complex development, just need to configure cleverly in the template.### Understanding the navigation mechanism of Anqi CMS Anqi CMS is built with a flexible template tag system, the core of which is the "navigation list tag"

2025-11-08

How to set and display the common areas of the website such as header, footer, and sidebar in AnQiCMS?

In website operation, the header, footer, and sidebar, etc., play a crucial role.They not only carry the brand image and navigation function, but also the key to improving user experience and content distribution efficiency.For those who use AnQiCMS, understanding how to efficiently set up and display these areas will greatly enhance the professionalism and operational convenience of the website.AnQiCMS as an enterprise-level content management system based on the Go language, has fully considered the flexibility and scalability of templates from the very beginning.This means, whether it is to build a simple corporate website

2025-11-08

How to correctly display the breadcrumb navigation path on a web page?

Elegantly configure breadcrumb navigation in AnQiCMS: Improve user experience and SEO performance When you visit a website, breadcrumb navigation is like a considerate guide, it can clearly tell you where the current page is in the website structure.From the home page all the way to the page you are browsing, it not only helps users quickly understand the website hierarchy, but also makes it convenient for them to backtrack to the upper page.For the website's search engine optimization (SEO), a reasonable breadcrumb navigation can also help search engines better understand the website structure, thereby possibly bringing better crawling and ranking effects

2025-11-08

How to set and display the SEO title, keywords, and description (TDK) of a website in AnQiCMS?

When building a website, Search Engine Optimization (SEO) is the key to ensuring that content is discovered by search engines and attracts potential visitors.And the SEO title (Title), keywords (Keywords), and description (Description), abbreviated as TDK, are one of the most basic and most important elements in website optimization.They directly affect the display and click-through rate of websites in search results.

2025-11-08