How to create a dynamic breadcrumb navigation using the `breadcrumb` tag and customize the home page name and title display?

Calendar 👁️ 62

In website operation, a clear navigation path is crucial for user experience and search engine optimization (SEO).Breadcrumb Navigation is like a small map of a website, allowing visitors to always understand their own location and easily return to the previous page.Today, let's delve into how to make full use of the powerful features in Anqi CMS.breadcrumbLabel, create dynamic breadcrumb navigation, and customize the home page name and title display according to our needs.

Know about AnQi CMSbreadcrumbTag

AnQi CMS is designed to simplify website development and content management by providing many intuitive and powerful template tags.breadcrumbTags are one of them, they can automatically generate the complete path from the current page to the homepage, greatly reducing the manual writing of navigation code.

The usage of this tag is very consistent with the Anqi CMS template engine style, which is based on the Django template engine syntax, allowing you to easily call and customize it in template files. The basic structure is:

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

Here, crumbsThis is the variable name we give to the breadcrumb navigation list, you can name it freely.{% for item in crumbs %}In the loop, eachitemContainsName(link name) andLinkTwo fields, (link address), for convenience in building visual navigation elements.

Create dynamic breadcrumb navigation

The most basic breadcrumb navigation, simply call itbreadcrumbLabel, it will automatically detect the current page type (such as article details, category list, single page, etc.), and generate the corresponding path.

A basic breadcrumb navigation structure may look like this:

<nav class="breadcrumb">
    {% breadcrumb crumbs %}
    <ul>
        {% for item in crumbs %}
            <li><a href="{{ item.Link }}">{{ item.Name }}</a></li>
            {% if not forloop.Last %}
                {# 如果不是最后一个元素,添加分隔符 #}
                <li class="separator"> &gt; </li>
            {% endif %}
        {% endfor %}
    </ul>
    {% endbreadcrumb %}
</nav>

This code will traversecrumbsEach breadcrumb item in the array generates a link.forloop.LastIt is a very useful auxiliary variable, which can determine whether the current loop is the last element, thus helping us correctly add or omit separators (such as&gt;)。Through simple CSS styles, you can make it present a beautiful visual effect.

Customize the homepage name: make your website more personalized

By default, the first element of the Anqi CMS breadcrumb navigation is "Home page". If you want to modify it to a more characteristic name according to the brand style or target user group of the website, such as "My Blog", "Company Homepage", or a specific brand name,breadcrumblabel'sindexParameters can be put to good use.

Just inbreadcrumbthe tag withindexParameters and specify the name you want:

<nav class="breadcrumb">
    {% breadcrumb crumbs with index="我的博客首页" %}
    <ul>
        {% for item in crumbs %}
            <li><a href="{{ item.Link }}">{{ item.Name }}</a></li>
            {% if not forloop.Last %}
                <li class="separator"> &gt; </li>
            {% endif %}
        {% endfor %}
    </ul>
    {% endbreadcrumb %}
</nav>

Now, your breadcrumb navigation will start with 'My Blog Homepage', consistent with the overall style of the website.

Control title display: Flexible to meet different page needs

On the article detail page or product detail page, the last element of the breadcrumb navigation is usually the title of the current page. Anqi CMS'sbreadcrumbTags providedtitleParameters, allowing you to control the display of this section more flexibly.

titleParameters support three settings:

  1. title=true(default)This is the default behavior, the last element of the breadcrumb will display the full title of the current page.
  2. title=falseIf you do not want the title of the current page to be displayed in the breadcrumbs, you can choose to turn it off.For example, under certain design styles, the title of the current page may already be very prominent in the page content, so there is no need to repeat it in the breadcrumbs.
  3. title="自定义标题"You can replace the title of the current page with a custom string.This is very useful when you need to simplify display or unify style, for example, at the end of the breadcrumb of all article detail pages, it displays "Article Details" instead of the specific article title.

Here is the code example for these three cases:

1. Show full title (default behavior or explicitly set)title=true):

<nav class="breadcrumb">
    {% breadcrumb crumbs with index="我的站点" title=true %}
    <ul>
        {% for item in crumbs %}
            <li><a href="{{ item.Link }}">{{ item.Name }}</a></li>
            {% if not forloop.Last %}
                <li class="separator"> &gt; </li>
            {% endif %}
        {% endfor %}
    </ul>
    {% endbreadcrumb %}
</nav>

This will display effects similar to “My site > Category name > Article title”.

2. Do not display the current page title (title=false):

<nav class="breadcrumb">
    {% breadcrumb crumbs with index="我的站点" title=false %}
    <ul>
        {% for item in crumbs %}
            <li><a href="{{ item.Link }}">{{ item.Name }}</a></li>
            {% if not forloop.Last %}
                <li class="separator"> &gt; </li>
            {% endif %}
        {% endfor %}
    </ul>
    {% endbreadcrumb %}
</nav>

On the article detail page, it will only display “My site > Category name”, and the article title will be omitted.

3. Use Custom Title (title="文章详情页"):

<nav class="breadcrumb">
    {% breadcrumb crumbs with index="我的站点" title="文章详情页" %}
    <ul>
        {% for item in crumbs %}
            <li><a href="{{ item.Link }}">{{ item.Name }}</a></li>
            {% if not forloop.Last %}
                <li class="separator"> &gt; </li>
            {% endif %}
        {% endfor %}
    </ul>
    {% endbreadcrumb %}
</nav>

On the article detail page, it will display “My site > Category name > Article detail page”, and replace the specific article title with “Article detail page”.

Combine practical application: complete example code

By flexible applicationindexandtitleParameters, you can create a breadcrumb navigation that is both practical and beautiful based on the brand strategy of the website and the user experience goals. Here is an example that combines customized home page names and custom title display:

<style>
    .breadcrumb ul {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        align-items: center;
        flex-wrap: wrap; /* 适应小屏幕换行 */
    }
    .breadcrumb li {
        margin-right: 5px;
        font-size: 14px;
        color: #666;
    }
    .breadcrumb li a {
        color: #337ab7;
        text-decoration: none;
    }
    .breadcrumb li.separator {
        color: #999;
        margin: 0 5px;
    }
    .breadcrumb li:last-child a {
        color: #333; /* 最后一个元素通常颜色更深或不可点击 */
        cursor: default;
    }
    .breadcrumb li:last-child.separator {
        display: none; /* 隐藏最后一个分隔符 */
    }
</style>

<nav class="breadcrumb">
    {% breadcrumb pathItems with index="公司官网" title="当前页面" %}
    <ul>
        {% for item in pathItems %}
            <li>
                <a href="{{ item.Link }}" {% if forloop.Last %}aria-current="page"{% endif %}>
                    {{ item.Name }}
                </a>
            </li>
            {% if not forloop.Last %}
                <li class="separator"> &gt; </li>
            {% endif %}
        {% endfor %}
    </ul>
    {% endbreadcrumb %}
</nav>

This code not only demonstrates how to customize the homepage

Related articles

How to construct a website navigation with multi-level submenus and associated content using the `navList` tag?

When building a website, a clear and easy-to-use navigation system is crucial, as it directly affects whether users can quickly find the information they need and also influences how search engines understand the structure of the website.AnQiCMS provides a powerful `navList` tag, allowing us to flexibly build a navigation system with multi-level submenus and closely associate navigation items with website content.Next, we will delve into how to use the `navList` tag to create a set of multi-level navigation that is both beautiful and practical for your website.### Website Navigation Basics

2025-11-07

How to dynamically generate page title, keywords, and description with the `tdk` tag and flexibly control whether to include the website name?

In website operation, the page title (Title), keywords (Keywords), and description (Description), which we commonly refer to as TDK, are the foundation of search engine optimization.They can not only help search engines understand the page content, but are also key factors to attract users to click.AnQiCMS (AnQiCMS) fully understands the importance of TDK, and through its powerful template tag system, especially the versatile `tdk` tag, makes dynamic generation and flexible control of page TDK easy and efficient.

2025-11-07

How to use the `stampToDate` tag to format a timestamp into a custom date and time format?

Good, I'm glad to deeply interpret the `stampToDate` tag of AnQiCMS, helping you easily control the time display on the website. --- ## Flexible Time Mastery: Customize Date and Time Format with AnQiCMS `stampToDate` Tag The way dates and times are displayed on a website often directly affects user experience and the clarity of information communication in content management.A concise and readable date format allows visitors to quickly understand the timeliness of the content. AnQiCMS

2025-11-07

How to correctly configure the `pagination` tag to generate a functional pagination navigation on the list page?

In website content management, configuring a fully functional pagination navigation for the list page is a key factor in improving user experience and optimizing the website structure.AnqiCMS (AnqiCMS) provides a simple and powerful `pagination` tag, allowing developers to easily meet this need.To make the `pagination` tag generate the pagination navigation correctly on the list page, it is first necessary to understand its mechanism and the collaborative relationship with content list tags (such as `archiveList`).

2025-11-07

How to perform content filtering, batch replacement, and recycle bin operations in the document management feature of the AnQiCMS backend?

The content management system is the core of website operation, especially for sites that update content frequently, efficient document management functions are crucial.AnQiCMS as a powerful content management system, provides a rich and practical background document management tool, helping operators easily handle daily content maintenance work.This article will delve into the functionality of AnQiCMS backend in content filtering, batch replacement, and recycle bin operations, helping you manage website content more efficiently.### Efficient Filtering: Quickly Locate Target Content Quickly locate the required information in the vast amount of website content

2025-11-07

How to create and manage custom content models in AnQiCMS and add specific fields to them?

In daily website operations, we often encounter the need to publish various types of content.In addition to common articles and product displays, you may also need a dedicated "event list" to post the latest events, or a "team members" page to showcase the core team of the company, or even a "successful case" module to share project experience.AnQiCMS was designed with this flexibility in mind, providing powerful custom content model features, allowing us to flexibly create and manage different types of content structures according to our actual business needs. So

2025-11-07

How to implement the image classification, batch transfer, and quick replacement operations of the image resource management function?

## Make image management no longer a hassle: Anqi CMS classification, batch transfer, and quick replacement feature details In this visually content-driven era, images on websites are not only auxiliary to content but also key elements that attract users, enhance experience, and even affect search engine rankings.However, as the content of the website becomes richer, the number of images also increases, and if these images are just scattered together, it will be extremely difficult to search and manage, and even slow down the efficiency of content updates.AanQi CMS understands the importance of image management for website operation

2025-11-07

How does the newly added Markdown editor of AnQiCMS support the correct display of mathematical formulas and flow charts?

## Make Content More Vivid: How AnQiCMS Markdown Editor Elegantly Presents Mathematical Formulas and Flowcharts The recent upgrade of AnQiCMS has brought an integrated Markdown editor, which undoubtedly brings great convenience to content creation.For operators who need to write technical documents, tutorials, reports, or any content that includes complex logic display, it is undoubtedly a blessing to be able to directly insert mathematical formulas and flowcharts into the article and have them displayed correctly.This article will discuss in detail how to implement this feature in AnQiCMS

2025-11-07