How to display first and second level menus and their links in the website's main navigation?

Calendar 👁️ 71

As an experienced website operations manager, I am well aware of the importance of a clear and intuitive navigation system for website user experience and content discovery.AnQiCMS (AnQiCMS) with its flexible content management functions, allows us to easily build navigation structures that meet various business needs.Today, I will detail how to cleverly set up and display the first and second-level menus and their links in the website's main navigation based on the powerful functions of AnQiCMS.

Understanding the navigation system of AnQi CMS

The navigation system of Anqi CMS is designed beautifully, it allows us to create multiple 'navigation categories' for the website.This means that in addition to the traditional main navigation, you can also create different menu groups for the website as needed, such as footer navigation, sidebar navigation, etc.Under each navigation category, we can add various types of links, which can point to the core content within the website, such as article categories or independent single pages, and can also flexibly link to external websites.This layered and highly customizable design makes the website's content organization structure clear and easy to understand, greatly facilitating users' browsing and access to information.

Configure the main navigation category

To begin building your website navigation, you first need to log in to the Anqi CMS backend management interface.Please navigate to the "Backend Settings" option in the left menu bar and then select the "Navigation Settings" option.On this page, you will see a section named "Navigation Category Management".The system usually provides a default "Default Navigation" category that you can use as your main navigation.Of course, if you wish to have a clearer menu structure management, you can also click the 'Add Navigation Category' button to create a new category, such as naming it 'Main Navigation' or 'Top Navigation'.Once you select or create the main navigation category, all first-level and second-level menus will belong to this specific category for centralized management.

Add primary navigation menu

Next, we will start creating the primary navigation menu item in the "Navigation Link Settings" area.Please click the 'Add Navigation Link' button at the top of the page. The critical step in the subsequent configuration form is the selection of the 'Parent Navigation' option.Here, you need to select 'Top-level Navigation', which clearly indicates that you are creating a standalone, independent main menu that does not belong to any other menu.

The 'Display Name' field is used to fill in the menu text that users actually see on the website front-end, please ensure that it is clear and concise. The 'Link Type' is the core setting that defines the menu behavior, AnQi CMS provides three main types for you to choose from:

  • Built-in linkThis type of link is preset to point to common targets such as the homepage of a website, the homepage of a specific content model (such as an article model or product model), etc., making it convenient for quick configuration.
  • Category page linkThrough this option, you can easily select the article categories, product categories, or independent single pages created on the website as navigation targets, directing users to specific content lists or detail pages.
  • External linkIf you need to redirect users to any custom URL within the site or completely jump to an external website, you can select this type and fill in the complete link address. Select the link type that suits your needs and then enter the corresponding link address or select the specific content according to the prompts.The "Display Order" field determines the arrangement position of menu items, the smaller the number, the earlier the menu item is displayed in the navigation bar.

Create a second-level navigation menu

To add a secondary dropdown menu to an established primary navigation, the operation process is very similar to adding a primary menu, but the most critical difference lies in the selection of the 'parent navigation'.You need to click the "Add Navigation Link" button again, in the pop-up form, at this time, "Parent Navigation" should no longer select "Top Level Navigation", but should accurately select the "Display Name" of a first-level navigation you created earlier.For example, if you have set a top-level navigation named 'Product Category', then you should select 'Product Category' as the parent navigation here.Such links as 'electronics', 'home appliances', and the like, which you create, will automatically become a second-level submenu under 'Product Category', and will be displayed in a drop-down form.The settings such as "Display Name", "Link Type", and "Display Order" will follow the same logic as when adding a top-level menu.Our AnQi CMS currently supports up to two levels of navigation, which is enough to build the hierarchical structure required by most websites, ensuring the practicality and ease of use of navigation.

Navigation call in the template

After completing the navigation configuration of the Anqi CMS backend, the next step is to render these carefully set menus to the front end of the website. Typically, this task is performed in the public part of your website template, such asheader.htmlorbase.htmlThese files. Anqi CMS provides a specialnavListtag to retrieve and output the navigation data you have configured.

The following is a basicnavListLabel usage example, it can display a navigation structure containing first and second-level menus:

`twig {% navList navs %} {# Get all navigation data and assign it to the variable navs #}

    {%- for item in navs %} {# 遍历一级菜单项 #}
        <li class="{% if item.IsCurrent %}active{% endif %}"> {# 根据 IsCurrent 属性添加激活样式 #}
            <a href="{{ item.Link }}">{{item.Title}}</a>
            {%- if item.NavList %} {# 检查当前一级菜单项是否包含二级子菜单 #}
            <dl> {# 如果存在二级菜单,则使用 dl 标签包裹 #}
                {%- for inner in item.NavList %} {# 遍历二级菜单项 #}
                    <dd class="{% if inner.IsCurrent %}active{% endif %}"> {# 根据 IsCurrent 属性添加激活样式 #}
                        <a href="{{ inner.Link }}">{{inner.Title}}</a>
                    </dd>
                {% endfor %}
            </dl>
            {% endif %}
        </li>
    

Related articles

How to obtain the global system configuration information such as website name, Logo, etc?

As a website operator proficient in AnQi CMS content management, publishing, and optimization, I fully understand the importance of obtaining global website configuration information for website construction and daily maintenance.This information constitutes the basic framework of the website, including brand identification, contact information, SEO metadata, etc., ensuring the uniformity, professionalism, and maintainability of the website.In Anqi CMS, obtaining these global system configuration information is intuitive and flexible, mainly achieved through built-in template tags.

2025-11-06

How to implement pagination for the article list display function?

As a website operator who is deeply familiar with the operation of AnQiCMS, I understand that it is crucial to organize and present a large number of articles efficiently in content display.The pagination feature not only greatly enhances the user's browsing experience, but also avoids the visual fatigue caused by too much content on a single page, and is an indispensable part of the SEO strategy.To implement pagination display of article lists in AnQiCMS, it benefits from its flexible template engine and dedicated tag system, making the whole process clear and efficient.

2025-11-06

How to filter and display the article list according to a specified category ID?

As an experienced CMS website operation person, I know the importance of content organization and display for user experience and SEO.In daily work, we often need to filter and display article lists according to specific categories so that readers can quickly find the content they are interested in.Today, I will elaborate on how to flexibly and efficiently filter and display article lists in AnQiCMS according to specified category IDs.The categorization of content is the foundation for the effective operation of a website.

2025-11-06

How to loop and display the latest 10 articles in the template?

As an experienced CMS website operation personnel, I fully understand the core position of content in website operation.Dynamically displaying the latest content can not only improve the user experience, but also effectively increase the activity of the website and the frequency of search engine crawling.Below, I will elaborate on how to loop and display the latest 10 article lists in the AnQiCMS template.

2025-11-06

How to dynamically generate the breadcrumb navigation path of the current page?

As an expert who deeply understands the operation of AnQiCMS, I know that a clear and easy-to-use navigation system is crucial for both website visitors and search engines.Breadcrumb Navigation is an effective tool that improves user experience and website SEO performance.It can directly display the user's current position in the website structure, helping them easily backtrack, and also provide clues for search engines about the website's hierarchical structure.

2025-11-06

How to get the title and link of the previous and next articles of the current article?

As an experienced website operator familiar with AnQi CMS, I am well aware of the importance of article navigation in content management for improving user experience and optimizing website structure.When a reader is browsing an article meticulously crafted, if they can conveniently jump to the previous and next related or sequential articles, it not only extends the user's stay on the website, increases the page views, but also conveys a better internal link structure to search engines, thereby helping to improve the website's SEO performance.The AnQi CMS provides simple and powerful template tags

2025-11-06

How to display the detailed information (name, description, image) of a category on the category page?

As an experienced CMS website operation personnel of an enterprise, I am well aware of the core position of the classification page in the website structure and user experience.A well-designed, informative category page not only helps users quickly find the content they need, but also enhances the overall professionalism of the website through clear hierarchy and attractive visual elements, and is also crucial for search engine optimization (SEO).Today, I will elaborate on how to effectively configure and display the detailed information of category pages in Anqi CMS, including their names, descriptions, and associated images.### Enhance User Experience and SEO

2025-11-06

How to get all the top-level category lists and display them on the page?

## A Safe CMS: How to obtain and display all top-level category lists on a website page As a website operator, I am well aware of the importance of a clear website structure for user experience and search engine optimization (SEO).Category navigation is one of the core elements of website content organization, it not only guides users to quickly find the information they need, but also helps search engines better understand the hierarchy of website content.AnQiCMS (AnQiCMS) provides a直观 and powerful template tag system, allowing website operators to easily manage and display the classification structure of the website.

2025-11-06