How to customize the website navigation menu to display multi-level content links?

Calendar 👁️ 80

During the process of building and operating a website, the navigation menu plays a crucial role.It is not only the guidance for users to explore the content of the website, but also the key for search engines to understand the structure of the website.AnQiCMS (AnQiCMS) understands this point and therefore provides flexible and powerful navigation menu customization features, allowing us to easily implement multi-level content link display, thereby optimizing user experience and enhancing the overall efficiency of the website.

Next, we will together learn how to customize and manage the website navigation menu in Anqi CMS, and make it flexible to display multi-level content links.

Step 1: Configure the navigation menu on the backend

The navigation settings of Anqi CMS are concentrated in the background management interface, through simple and intuitive operations, we can define menus at different locations and add rich link content.

1. Access Navigation Settings

First, log in to your AnQi CMS backend. In the left menu bar, find and click "Backend Settings", and then select "Navigation Settings".This is the center where you manage all website navigation.

2. Manage Navigation Categories

After entering the navigation settings page, you will see a "Navigation Category Management" area.The Aanqi CMS defaults to providing a "Default Navigation" category, but this is far from enough.Imagine that your website may need to display the main navigation in the header, the footer may display links or legal statements, the sidebar may display popular categories, and even websites in different languages may need independent navigation.

The AnQi CMS allows you to create multiple navigation categories based on your actual needs.For example, you can add a new category named "Footer Navigation" or "Sidebar Menu".Each category has a unique ID, which will be used in subsequent front-end template calls.With different categories, you can configure dedicated navigation menus for different areas of the website to achieve more fine-grained layout management.

3. Add and Edit Navigation Links

Now, we begin to add specific links for the selected navigation category.Click the 'Add New Navigation' button in the 'Navigation Link Settings' section, or click the 'Edit' button next to an existing navigation.

  • Set Link Levels: AnQi CMS supports up to two levels of navigation links, which is enough to meet the needs of most websites.When you add a new link, you can decide its level by selecting the "Parent Navigation" option.If you select "Top Navigation", it will be displayed as a first-level menu item;If a first-level navigation that already exists is selected, it becomes a second-level submenu under that first-level navigation.This hierarchical relationship is the basis for displaying multi-level content.

  • Enter Link Display Information:

    • display nameThis is the navigation link text displayed on the front page, and it can be freely modified as needed.
    • Subheading nameIf your navigation needs to display dual titles (such as Chinese-English translation), you can add subtitles here.
    • Navigation description: Provide a brief introduction for the navigation link, which can be used to display tips in some template designs.
  • Select link typeThe Anqi CMS provides various link types to meet the needs of different content connections:

    • Built-in linkIncluding the homepage of the website, the article model homepage, the product model homepage, and other custom model homepages.Select these link types, the system will automatically generate the corresponding URL, very convenient.
    • Category page linkThis is the key to connecting multi-level content. You can select from the article categories, product categories, or single pages you have created.In this way, your navigation can directly point to a list page of a certain category or a specific single page, allowing users to quickly find the content they need.
    • External linkIf you need to link to a specific page within the site, an external website, or a custom URL, you can select this option and manually enter the complete link address.
  • Adjust display orderEach navigation link can be set to have a 'display order' value, where a smaller number means the link is displayed closer to the top in the navigation menu.Although drag and drop sorting is not currently supported, you can still flexibly control the arrangement of menu items by adjusting the numbers.

After completing the above settings, click “OK” to save your navigation configuration.

Step 2: Front-end template call and display

After the navigation menu is configured on the backend, we need to call and display them in the website's frontend template.The Anqi CMS adopts syntax similar to the Django template engine, using specific tags to retrieve and render data.

1. Core tagnavListUsage of

In the AnQi CMS template system, the core tag used to call the navigation menu isnavList. Its basic usage is as follows:

{% navList navs with typeId=1 %}
    {# 在这里循环输出导航项 #}
{% endnavList %}

navListThe tag usually needs to be paired withwith typeIdParameter, specify the navigation category ID you created in the background. For example,typeId=1Indicates calling the "default navigation" category.navsis a custom variable name used to receive the navigation data obtained, it is an array object, you need to useforloop to iterate through each navigation item.

Each navigation item (for exampleitem) contains the following fields, which can be called in the template:

  • {{item.Title}}:Display name of the navigation link.
  • {{item.Link}}:URL address of the navigation link.
  • {{item.IsCurrent}}A boolean value indicating whether the current page is this navigation link. It can be used to addactiveStyle.
  • {{item.NavList}}This is a key field, if the current navigation item has a sub-navigation, it will contain a sub-navigation list, and you can display a multi-level structure by looping again.

2. Basic two-level navigation display

Based onnavListLabel, we can easily build a basic two-level navigation menu. Please note that this code snippet is just a structural example, and you need to beautify it according to your own CSS style.

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

This code will iterate through all first-level navigation items, if a first-level navigation item containsNavList(meaning it has sub-navigation), it will loop back to output all the second-level navigation items, thus realizing a two-level menu structure.

3. Expansion: Integrating content lists into navigation.

The strength of AnQi CMS lies in the fact that you can not only link to categories or pages, but also dynamically display the latest articles or product lists under these categories in the navigation menu.This is a very practical feature for the "Multi-level Content Link Display" theme.

Assuming you want to click on a second-level navigation (a category) under a first-level navigation, so that the dropdown menu not only displays the subcategories of this category but also lists the latest documents under this category. This can be achieved by combiningarchiveListorcategoryListTag implementation.

Example 1: Display subcategories and the latest products under the second-level navigation

`twig

Related articles

How to set independent TDK (title, description, keywords) for the homepage of a website to optimize search results display?

How to make your website stand out among a vast amount of information and gain more exposure in website operation?In this case, Search Engine Optimization (SEO) plays a vital role, and the title (Title), description (Description), and keywords (Keywords), which we commonly refer to as TDK, are the cornerstone of SEO strategy.For users of AnQiCMS, setting up independent homepage TDK is not only simple and efficient, but also a key step in optimizing website search performance.Why is the TDK setting on the homepage crucial

2025-11-08

How to dynamically display contact information in website templates?

When operating a website, we often need to display the company's contact information, such as phone, email, address, and even social media links.The traditional way might be to hardcode this information directly in the template, but this means that every time the contact information changes, you need to modify the code, which is麻烦 and easy to make mistakes.AnQiCMS (AnQiCMS) provides a flexible and efficient solution that allows you to easily display and manage these contact methods in website templates.This means that once the contact information changes, you only need to update it once in the background

2025-11-08

How to flexibly call the system global configuration information for display in the website template?

Flexibly calling the system global configuration information in the website template is a key step in building a dynamic and easy-to-maintain website.AnQiCMS (AnQiCMS) fully understands this need and therefore provided powerful and intuitive template tags from the outset, allowing users to easily display preset system-level data, contact information, and even customized information at any position on the page.The Anqi CMS template system adopts a syntax similar to the Django template engine, where variables are usually defined using double curly braces `{{ variable_name }}`, and various operations and tags are through single curly braces and percent signs

2025-11-08

How does AnQiCMS improve the loading speed and display experience of website content through static caching?

In today's fast-paced digital world, the loading speed of websites and user experience are crucial.A fast-reacting website can not only effectively retain visitors but also improve search engine rankings and bring more exposure to the content.AnQiCMS, as an enterprise-level content management system developed based on the Go language, has always regarded high performance as one of its core goals from its initial design, and has significantly improved the speed of website content loading and display experience through this key technology of static caching.Static caching, in simple terms, is the process of pre-generating static HTML files for a website's dynamic content

2025-11-08

How to filter and display content under specific models or categories on the document list page?

When managing website content, we often need to display specific types or themes of content on different list pages, such as article lists, product showcase pages, or detailed summaries of custom models.This not only concerns whether users can find the information they need efficiently, but also directly affects the overall layout and user experience of the website.Anqi CMS with its flexible content model and efficient system architecture provides us with powerful tools to accurately filter and personalize content display.### The Core of Content Organization: Models and Classification In AnQi CMS

2025-11-08

How to display custom model field information in the document list?

In Anqi CMS, the flexibility of the content model is one of its outstanding advantages.Many times, we not only need to display rich content on the document detail page, but also hope to see key custom information at a glance on the document list page, such as product models, article authors, property prices, vehicle mileage, and so on.This information is often an important basis for users to quickly screen and understand the content.This article will detail how to cleverly display these custom model field information in the document list of Anqi CMS.

2025-11-08

How to manage and display single-page content on the website, such as 'About Us'?

Manage and display single-page content in Anqi CMS: from creation to optimization Most websites cannot do without static pages such as "About Us", "Contact Information", and "Privacy Policy".These pages, although relatively fixed in content, are important windows for users to understand the website and establish trust, and are also key factors for search engines to evaluate the professionalism of the website.AnQi CMS understands the importance of these pages and provides a set of intuitive and powerful tools that allow you to easily manage and beautifully display this single-page content.

2025-11-08

How to classify and manage uploaded image resources, and optimize the front-end display?

In the process of using AnQiCMS to manage website content, the management and optimization of image resources is an essential element for improving website user experience and SEO performance.A well-organized image library not only makes daily operations more efficient, but also ensures that website content is presented in **status across different devices and network environments. ### Picture Resource Classification Management: Say goodbye to chaos and have everything in order AnQi CMS provides us with an intuitive picture resource management interface, making a large number of pictures no longer a problem of piles.To start organizing, we just need to go to the back end

2025-11-08