How to display breadcrumb navigation in AnQiCMS template and customize the home page name or whether to include the current page title?

Calendar 👁️ 76

Have you ever felt a bit confused while browsing websites on a daily basis?Breadcrumb Navigation is like leaving a series of small markers along the way when you explore a new place, allowing you to clearly know where you came from and where you are now.It can not only significantly improve the user experience of the website, help visitors quickly understand the website structure, but also greatly benefit from search engine optimization (SEO), because it provides clear website hierarchy information for search engine spiders.

In AnQiCMS, thanks to its powerful and flexible template system, we can easily implement and customize breadcrumb navigation in the website template, including customizing the home page name and flexibly controlling the display of the current page title.

Display breadcrumb navigation in AnQiCMS template

To add breadcrumb navigation to the AnQiCMS template, you need to use the built-in system.breadcrumbLabel. This label is usually placed in the common part of each page, such as a file namedpartial/header.htmlorpartial/breadcrumb.htmlThen it is accessed through{% include 'partial/breadcrumb.html' %}Such a label is introduced on pages where breadcrumbs need to be displayed.

breadcrumbThe label automatically identifies the current page path and outputs the hierarchical structure as a namedcrumbsThe array object. You can go throughfora loop to iterate over thiscrumbsarray, then name each navigation item (Name) and link (LinkRender to the page.

Below is a basic breadcrumb navigation code example, you can add it to your template file:

<nav aria-label="breadcrumb">
    {% breadcrumb crumbs %}
    <ol class="breadcrumb">
        {% for item in crumbs %}
            {% if forloop.Last %}
                {# 最后一个元素是当前页,通常不带链接,并可加active类 #}
                <li class="breadcrumb-item active" aria-current="page">{{ item.Name }}</li>
            {% else %}
                {# 其他元素是可点击的链接 #}
                <li class="breadcrumb-item"><a href="{{ item.Link }}">{{ item.Name }}</a></li>
            {% endif %}
        {% endfor %}
    </ol>
    {% endbreadcrumb %}
</nav>

In this example,forloop.LastIt is a very useful built-in variable that helps us determine whether the current element being looped through is the last one in the array.This way, we can apply a different style or remove the link of the last element in the breadcrumb (i.e., the current page).

Customize the home page name of the breadcrumb navigation

AnQiCMS'breadcrumbTags provide aindexParameter, allows you to easily modify the display text of the home page in the breadcrumb navigation. By default, the home page will display as "home".

If you want to change the home page name to 'My Homepage' or any other personalized text, just inbreadcrumbthe tag withindexthe parameter and assign the corresponding value:

<nav aria-label="breadcrumb">
    {% breadcrumb crumbs with index="我的AnQiCMS主页" %}
    <ol class="breadcrumb">
        {% for item in crumbs %}
            {% if forloop.Last %}
                <li class="breadcrumb-item active" aria-current="page">{{ item.Name }}</li>
            {% else %}
                <li class="breadcrumb-item"><a href="{{ item.Link }}">{{ item.Name }}</a></li>
            {% endif %}
        {% endfor %}
    </ol>
    {% endbreadcrumb %}
</nav>

By simpleindex="你的自定义名称"Set, the first item of the breadcrumb navigation will display according to your wishes. If you do not want to display the home page name, you can also try setting it to an empty string, for exampleindex=""Please note the actual display effect, to ensure it meets your expectations.

Control whether to include the current page title and customize its name.

Besides the home page name, the last element of the breadcrumb navigation is usually the title of the current page. AnQiCMS also provides flexibletitleparameters to control the display of this part.

titleThere are several ways to use the parameter:

  1. Display the full title of the current page (default behavior): If you do not settitleparameter, or set it explicitlytitle=truethe last item of the breadcrumb will automatically display the full title of the current page.

    {# 默认行为,或者明确指定 title=true #}
    {% breadcrumb crumbs with index="网站首页" title=true %}
    
  2. Do not display the title of the current pageIf you

Related articles

How does AnQiCMS use the `navList` tag to build and display multi-level website navigation menus?

When building a website with comprehensive functions, a clear and intuitive navigation menu is the core of user experience.AnQiCMS provides a powerful template tag system, where the `navList` tag is specifically used to build and display a multi-level navigation menu for the website.It not only can display the navigation structure you configure in the background, but also help you convert technical details into user-friendly interactive experiences.### The Foundation of Building Navigation: Backend Settings Before using the `navList` tag, you first need to set up in AnQiCMS

2025-11-07

How to obtain and display the contact information of the website in AnQiCMS, such as phone, email, address, and social media links?

It is crucial to clearly display contact information when building and operating a website to establish user trust and provide customer support.AnQiCMS as an efficient content management system provides an intuitive way to manage and display this key information, whether it is traditional phone numbers, email addresses, or modern social media links, it can be easily realized. ### One, Back-end Configuration: Centralize Your Contact Information AnQiCMS has designed a centralized area for you to manage all website contact information in one place.

2025-11-07

How to retrieve and display the system global settings of AnQiCMS template, such as website name, Logo, filing number, and copyright information?

When building a website, some core information such as the website name, website logo, filing number, and copyright information are indispensable elements.These global settings not only help visitors quickly identify your brand, but also reflect the professionalism and compliance of the website.AnQiCMS provides a straightforward and flexible way to manage and present these system-level information in templates.Where can I set these global information?First, these important website information need to be unified configured in the AnQiCMS background.

2025-11-07

How to retrieve and display the list of Tag tags and their corresponding links for an article?

In a website with increasingly rich content, how to effectively organize and present information is crucial.The Tag label (usually referred to as keywords or tags) not only helps users find related content quickly, but is also an indispensable part of Search Engine Optimization (SEO).AnQi CMS understands this point, providing users with a powerful and flexible tagging function, allowing you to easily add tags to articles and display these tags and their corresponding links in multiple forms on the website front end.

2025-11-07

How AnQiCMS dynamically generates and displays page Title, Keywords, and Description (TDK) to optimize SEO?

In website operation, to make your content stand out in search engines, attract more target users, and cannot do without the careful setting of these three core elements: Title, Keywords, and Description (TDK).AnQiCMS knows the importance of TDK for SEO, and has integrated a complete dynamic TDK generation and management mechanism from the beginning of the system design, allowing you to flexibly and efficiently optimize every page of your website.

2025-11-07

How to enable multilingual support for AnQiCMS website and display language switch options in the front-end template?

Under the wave of globalization, websites no longer only serve local users. How to allow visitors from different language backgrounds to access and understand the content of the website without barriers has become an important challenge for many operators.AnQiCMS (AnQiCMS) fully understands this need, providing a flexible and powerful multilingual support solution to help websites easily expand into the international market.This article will introduce how to enable multilingual functionality on the AnQiCMS website and guide you to integrate language switching options in the front-end template to enhance user experience.

2025-11-07

How does AnQiCMS handle and display image resources, including automatic compression, conversion to WebP format, and watermark management?

In website content operation, images are indispensable elements to attract visitors and convey information, but their size, loading speed, and copyright protection are also focuses for operators.AnQiCMS as a content management system is well-versed in this field, therefore, it has integrated a series of intelligent image resource processing and optimization functions, aiming to help us manage website images more efficiently and effortlessly, and improve user experience and SEO performance.

2025-11-07

How to get and display the content and information of a single page (such as "About Us" or "Contact Us") in AnQiCMS template?

Manage and display single-page content in AnQi CMS, such as "About Us", "Contact Us", or "Terms of Service", which is a very common requirement in website operation.AnQi CMS provides developers with intuitive and powerful template tags, allowing you to easily retrieve and display information on the front end of the website.Understanding Single Page Content Management in AnQi CMS Firstly, we need to understand how AnQi CMS manages these 'single pages'.In the "Page Resources" module in the background, you can find the "Page Management" feature.

2025-11-07