How to use the breadcrumb navigation tag of AnQiCMS to display the current page path?

Calendar 👁️ 71

In website operation, a clear navigation path is crucial for user experience and Search Engine Optimization (SEO).A breadcrumb navigation is a kind of auxiliary tool that can significantly improve the usability of a website, allowing users to intuitively understand the position of the current page and providing a convenient way to quickly return to the parent page.In AnQiCMS, implementing breadcrumb navigation is very simple and flexible.

AnQiCMS provides a dedicated breadcrumb navigation tag for usbreadcrumbIt allows us to easily display the complete path from the homepage to the current page on any page of the website.This tag automatically identifies the hierarchical structure of the current page and generates the corresponding path data, greatly reducing the manual maintenance work of navigation.

Learn more about the breadcrumb navigation tag of AnQiCMS

UsebreadcrumbThe core of using tags to display page paths lies in understanding their basic structure and supported parameters. The usage form of this tag is usually:

{% breadcrumb crumbs with index="首页" title=true %}
    {# 在这里循环输出面包屑路径 #}
{% endbreadcrumb %}

Here, crumbsIs a variable name we define to receivebreadcrumbAll path information generated by the tag, it is an array object. Inside the tag, we can traverse thiscrumbsarray to display the path.

breadcrumbThe tag provides several practical parameters that allow for fine-grained settings according to needs:

  • indexparameters:This parameter allows you to customize the display text of the 'Home' in the breadcrumb navigation.By default, it will display as 'Home'. If you want to display it as 'Your Location' or any other more personalized name, just set it toindex="您的位置"Just do it.
  • titleparameters:Used to control the display method of the current page in the breadcrumb navigation (i.e., the last item in the path).
    • When set totitle=trueWhen (the default value) is used, it will display the full title of the current page.
    • When set totitle=falseIf it is, the title of the current page will not be displayed. This may be very useful in some design scenarios.
    • If you want to display a specific custom text on the current page instead of its original title, you can directly settitleto the text you want, for exampletitle="文章详情".
  • siteIdparameters:This parameter is mainly used in environments for multi-site management. If you only operate one website, you usually do not need to fill in this parameter.Under a multi-site scenario, it can be used to specify which site's breadcrumb data to retrieve.

crumbsEach element in the array (usually referred to asitem) contains two key fields that are used to build the complete navigation path:

  • Name:Represents the display name of the path segment, for example, 'Product Center', 'News Dynamic', or a specific article title.
  • Link:Represents the URL address corresponding to this path segment, which the user can click to jump to the corresponding page.

Practical: Display breadcrumb navigation on the page.

Now, let's look at an actual code example to see how to implement breadcrumb navigation in your AnQiCMS template.We usually place it at the top of the page, below the title, so that users can see it at a glance.

<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        {% breadcrumb pathItems with index="您的位置" title=true %}
        {% for item in pathItems %}
            <li class="breadcrumb-item{% if forloop.Last %} active{% endif %}">
                {% if forloop.Last %}
                    {# 路径的最后一项(当前页面)通常不作为链接,或只显示文本 #}
                    {{ item.Name }}
                {% else %}
                    {# 其他层级作为可点击的链接 #}
                    <a href="{{ item.Link }}">{{ item.Name }}</a>
                {% endif %}
            </li>
        {% endfor %}
        {% endbreadcrumb %}
    </ol>
</nav>

Code analysis:

  1. <nav aria-label="breadcrumb">...</nav>and<ol class="breadcrumb">...</ol>:This is a semantic structure commonly used when working with HTML5 and Bootstrap frameworks, which helps improve accessibility and facilitate the application of styles.
  2. {% breadcrumb pathItems with index="您的位置" title=true %}:This is the beginning part of the AnQiCMS breadcrumb tag. We will store the generated path data in a namedpathItemsIn the variable. Here we customized the home page display as "Your location", and ensured that the current page title will be displayed.
  3. {% for item in pathItems %}:We passforLoop throughpathItemsEach item in the array of paths.
  4. <li class="breadcrumb-item{% if forloop.Last %} active{% endif %}">:Create a list item for each path item.forloop.LastIs the loop variable provided by the AnQiCMS template engine, used to determine whether the current loop is the last item. If it is the last item, we will usually addactiveA class to highlight the current page through CSS.
  5. {% if forloop.Last %} {{ item.Name }} {% else %} <a href="{{ item.Link }}">{{ item.Name }}</a> {% endif %}:This is a very critical conditional judgment.
    • For the last item in the path (forloop.LastFor true, we usually only display its name ({{ item.Name }}), without making it a clickable link because it is the current page.
    • For other path items (forloop.LastIf it is false, we then wrap it in<a>tag, usingitem.LinkAs a link address,item.NameAs link text, make sure the user can click to return to the upper page.
  6. {% endfor %}and{% endbreadcrumb %}:They areforloop andbreadcrumbThe end tag of the tag.

By the above code, your AnQiCMS website can have a dynamically generated, clear breadcrumb navigation, for example:您的位置 > 新闻动态 > 行业新闻 > AnQiCMS 发布 v2.1.1 版本

The value of breadcrumb navigation is emphasized again

In an AnQiCMS content management system that focuses on efficiency and SEO optimization, fully utilizing the breadcrumb navigation tags can bring multiple benefits to your website:

  • Enhance user experience:Users can clearly know their position on the website and can quickly backtrack to the previous level or any level page, reducing a sense of disorientation.
  • Optimize the website structure:Breadcrumb navigation displays the page relationship in a hierarchical structure, which helps users and search engines understand the overall layout of the website.
  • Improve SEO performance:Search engines (such as Baidu, Google) like websites with clear structure very much.Breadcrumbs navigation provides a series of internal links, strengthens the correlation between pages, and helps pass the page weight.In addition, structured breadcrumb information is sometimes displayed as rich text snippets in search results, increasing the click-through rate of the website.

In summary, AnQiCMS providesbreadcrumbTags are a powerful and flexible tool that can help you easily build excellent breadcrumb navigation on your website, thereby enhancing user experience and the overall performance of the website.


Frequently Asked Questions (FAQ)

  1. Ask: Why did I addbreadcrumbthe tag, but the breadcrumb navigation did not appear on the page?Answer: If the breadcrumb navigation does not display normally, please first check if the tags are spelled correctly, and make sure that your template file includes the code for traversingcrumbsthe array.forLoop. Next, please confirm that the page you are currently visiting is at a level that can generate breadcrumbs (such as article detail pages, product category list pages, etc.).For a pure website homepage, there is usually no upper path, so the breadcrumb may only show one item, "Home".

  2. Ask: Does AnQiCMS's breadcrumb navigation automatically include the title of the current page?Yes, by default, when you do not settitlethe parameter or set it totitle=trueWhen, AnQiCMS'sbreadcrumbThe tag will automatically display the title of the current page as the last item in the breadcrumb path. If you do not want to display the title of the current page, you can settitle=false; If you want to display a custom text, such as "Learn more", you can settitle="了解详情".

  3. What benefits does breadcrumb navigation have for the SEO of a website?Answer: The benefits of breadcrumb navigation for SEO are mainly reflected in several aspects: it provides clear website hierarchy information for search engines, helping spiders better understand and crawl your website content; through the form of internal links, breadcrumb navigation can effectively pass page authority and improve the ranking of relevant pages within the website; in addition, well-structured breadcrumb navigation has the opportunity to be displayed as rich text snippets in search engine results pages (SERP), which can significantly improve the visibility and click-through rate of your search results.

Related articles

How to build and display a multi-level navigation menu in AnQiCMS template?

The website navigation is the first window for users to interact with the website. A clear and intuitive navigation system can greatly enhance the user experience and help visitors quickly find the information they need.AnQiCMS provides a flexible and powerful navigation management function, whether it is a simple single-level menu or a complex two-level, three-level, or even more hierarchical multi-level navigation, it can be easily realized.Next, we will learn in detail how to build and display multi-level navigation menus in AnQiCMS.## Backend Settings: The Foundation of Navigation Construction Navigation construction in AnQiCMS begins with careful configuration in the backend

2025-11-08

How to dynamically display the website's homepage TDK information in AnQiCMS?

The TDK of a website, which stands for Title (title), Description (description), and Keywords (keywords), is a basic element of Search Engine Optimization (SEO), which directly affects the display effect and user click intention of the website in the Search Engine Results Page (SERP).For the "face" of the website - the homepage, accurate and attractive TDK information is crucial.In AnQiCMS (AnQiCMS), managing and dynamically displaying the TDK information of the website homepage is a straightforward and efficient task

2025-11-08

How to display the website's contact phone number and address on the AnQiCMS front-end page?

In website operation, clearly and conveniently displaying the website's contact phone number and address is a key step in establishing user trust and promoting communication and interaction.For friends using AnQiCMS, the system provides a very flexible and intuitive way to manage and display this important contact information.This article will provide a detailed introduction on how to display the website's contact phone number and address on the AnQiCMS front-end page. ### Step 1: Enter contact information in the AnQiCMS backend Firstly, we need to ensure that the contact information of the website has been correctly entered in the backend.This is the foundation for displaying this information on the front end

2025-11-08

How to display custom copyright information in AnQiCMS templates?

In AnQiCMS website operation, the website footer usually carries important information, among which the copyright statement is not only a legal requirement, but also an embodiment of brand professionalism.Clear and dynamically updated copyright information that can enhance the professional image of the website and provide basic protection for the content.In AnQiCMS, managing and displaying custom copyright information on the website is a very intuitive and flexible operation.Next, we will learn how to set and display your custom copyright information in the AnQiCMS template.--- ### One

2025-11-08

How to get the category list of a specified content model and display it in AnQiCMS?

In AnQiCMS, flexibly obtaining and displaying the category list of the specified content model is the key to building a clear website structure and a good user experience.Whether it is product display, article archive, or service introduction, the category list plays an important navigation role.AnQiCMS's powerful template tag system makes this process intuitive and efficient.

2025-11-08

How to display detailed information and description of the current category in AnQiCMS?

When operating the AnQiCMS website, we often need to dynamically display detailed information and descriptions of the current category on the category page, such as the title, introduction, large picture, and even custom fields.This not only helps users better understand the theme of the current page, but also effectively improves the page's SEO performance.The Anqi CMS provides very flexible and intuitive template tags, making this task easy and simple.### Get to know the `categoryDetail` tag

2025-11-08

How to display the list and links of all single pages in AnQiCMS template?

In AnQiCMS, wanting to display a list and links of all single pages in a website template is actually a very common requirement, such as you may want to place a 'site map' or 'quick link' area at the bottom of the website, or you may need to list all 'service items' single pages in the sidebar.AnQiCMS provides a simple and powerful template tag that allows you to easily achieve this.### Understanding Single Page and Its Role In AnQiCMS, a single page (Page) is usually used to publish content that is relatively fixed

2025-11-08

How to get and display the content and title of a specific single page in AnQiCMS?

In AnQiCMS, a single page is a very practical part of the website structure, usually used to display static content such as "About Us", "Contact Information", etc.As a content operator, you may often need to retrieve and display the content and titles of specific single pages at different locations on the website.AnQiCMS provides an intuitive and powerful template tag, making this process very simple. ### Understanding Single Page in AnQiCMS One of the design philosophies of AnQiCMS is the high customizability of content.

2025-11-08