How to display dynamic breadcrumb navigation and customize its display in Anqi CMS?

Calendar 👁️ 65

When we browse websites, we often see a line at the top or bottom of the page indicating the current location's navigation path, which is what we usually call "Breadcrumbs".It not only clearly tells the user the current page\'s position in the website structure, but also effectively enhances the website user experience and search engine optimization (SEO) effects.AnQiCMS (AnQiCMS) is a powerful content management system that comes with a convenient way to generate and customize this dynamic breadcrumb navigation.

How to implement dynamic breadcrumb navigation in Anqi CMS?

The AnQi CMS is built-in with a powerful template tag system, which includes a special one for generating breadcrumb navigation.breadcrumbTag.The essence lies in its ability to intelligently construct a complete navigation path based on the context of the current page, whether it is an article detail page, category list page, tag page, or a single page.You do not need to manually write complex logic to determine the type and level of the current page, Anqí CMS will automatically complete this task.

When you call in the templatebreadcrumbWhen a tag is encountered, it returns an array containing all navigation nodes. Each node includesName(link name) andLink(Link address) Two key pieces of information, you can flexibly display these information on the front end.

Core tag and parameter parsing

breadcrumbThe basic usage of the tag is as follows:

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

Let's take a detailed look at this tag and its parameters:

  • crumbs(variable name): This is a custom variable name that will carry bybreadcrumbAn array of breadcrumb navigation nodes generated by tags. You can use{% breadcrumb ... %}and{% endbreadcrumb %}betweenforLoop through thiscrumbsarrays to render each navigation node one by one. Eachcrumbselement in the array is an object containingName(Link Name) andLink(Link Address).

  • index(Parameter)This parameter is used to set the first element of the breadcrumb navigation path, which is usually the home page link of the website.The default value is 'Home'.index="您的当前位置"to achieve.

  • title(Parameter): This parameter controls whether the current page title is displayed at the end of the breadcrumb navigation.

    • When set totitle=trueWhen the default value is used, the last node of the breadcrumb will display the full title of the current page.
    • When set totitle=falseAt that time, the last node of the breadcrumb will not display the title, which is usually used on list pages or in situations where a simpler display is needed.
    • You can also assign a specific string to it, for exampletitle="文章详情"This will display the custom text of the last node.
  • siteId(Parameter)This parameter is used in multi-site management scenarios. If you have multiple sites and want to call the breadcrumb data of other sites, you can do so bysiteId="站点ID"Specify. This parameter is not required in most single-site cases.

Application: Customize breadcrumb display method.

UnderstoodbreadcrumbAfter the core functions and parameters of the tag, let's take a look at how to use it in actual templates and customize its display mode.

Add basic structure and separator

The most common breadcrumb navigation is usually presented in an unordered list (<ul>) or an ordered list (<ol>), and a separator is used between each link (such as>or/)。The following is an example of implementing this basic structure in an Anqi CMS template:

<nav class="breadcrumb-nav">
    <ul>
        {% breadcrumb crumbs with index="首页" title=true %}
            {% for item in crumbs %}
                <li class="breadcrumb-item">
                    {% if not forloop.Last %} {# 如果不是最后一个节点(当前页面),则显示链接和分隔符 #}
                        <a href="{{ item.Link }}" class="breadcrumb-link">{{ item.Name }}</a>
                        <span class="breadcrumb-separator"> &gt; </span>
                    {% else %} {# 如果是最后一个节点(当前页面),只显示文本 #}
                        <span class="breadcrumb-current">{{ item.Name }}</span>
                    {% endif %}
                </li>
            {% endfor %}
        {% endbreadcrumb %}
    </ul>
</nav>

In this example, we usedforloop.LastTo determine if the current node being traversed is the last in the breadcrumb path.For non-last nodes, we add links and separators; for the last node, only its name is displayed, and different styles (such as bold or highlighting) can be applied to highlight the current page.

Custom homepage text and ending title

You can easily modify the home page text of the breadcrumb navigation according to your website brand or language requirements. For example, if your website is an e-commerce platform, you can change "home page" to "mall homepage":

{# 将首页文本改为“商城主页” #}
{% breadcrumb crumbs with index="商城主页" title=true %}
    {# ... 循环渲染面包屑 ... #}
{% endbreadcrumb %}

Similarly, depending on the page type, you may need to control the display of the end title. For example, on the category list page, you may not want the last node of the breadcrumb to repeat the category name:

{# 在列表页,不显示当前分类的标题 #}
{% breadcrumb crumbs with index="首页" title=false %}
    {# ... 循环渲染面包屑 ... #}
{% endbreadcrumb %}

Or, do you want the last breadcrumb node on all article detail pages to display a unified "Details"?

{# 在文章详情页,最后一个节点显示“文章详情” #}
{% breadcrumb crumbs with index="首页" title="文章详情" %}
    {# ... 循环渲染面包屑 ... #}
{% endbreadcrumb %}

CSS style beautification

The Anqi CMS template system is only responsible for generating HTML structure and data, and the specific visual presentation depends entirely on your CSS style. In the above example, we addedbreadcrumb-nav/breadcrumb-item/breadcrumb-link/breadcrumb-separatorandbreadcrumb-currentWait for CSS classes, you can use these classes to define the font, color, size, spacing, and layout styles for the breadcrumb navigation, making it consistent with the overall design style of your website.

Conditional judgment and special processing

For more advanced customization needs, you canforcombine within the loopifstatements based onitem.Nameoritem.LinkPerform a conditional judgment to handle specific nodes specially. For example, if a node is a 'product center', you may want to add an icon for it:

{% breadcrumb crumbs with index="首页" title=true %}
    {% for item in crumbs %}
        <li class="breadcrumb-item">
            {% if item.Name == "产品中心" %}
                <i class="icon-product"></i>
            {% endif %}
            {% if not forloop.Last %}
                <a href="{{ item.Link }}" class="breadcrumb-link">{{ item.Name }}</a>
                <span class="breadcrumb-separator"> &gt; </span>
            {% else %}
                <span class="breadcrumb-current">{{ item.Name }}</span>
            {% endif %}
        </li>
    {% endfor %}
{% endbreadcrumb %}

In this way, you can control every aspect of the breadcrumb trail in detail, meeting various complex display needs.

**Practical Suggestions

  • Keep it concise.:Breadcrumb navigation is designed to simplify navigation and avoid overly long or complex paths.
  • Ensure clickability.:Except for the current page (usually the last node of the breadcrumb), all breadcrumb nodes should be clickable links for easy user navigation.
  • Unified styleEnsure that the breadcrumb style and layout are consistent throughout the website to enhance user experience.
  • Multi-type page testingOn the homepage, category page, detail page, tag page, and even the search results page of the website, test the breadcrumb display effect to ensure its correctness and consistency.

Security CMS

Related articles

How to implement flexible navigation menu and submenu display in AnQi CMS template?

In website operation, a clear and intuitive navigation menu is the core of user experience.It can not only help visitors quickly find the information they need, but it is also a direct embodiment of the structure and content organization logic of the website.AnQiCMS (AnQiCMS) leverages its efficient architecture based on the Go language and Django-style template engine to provide great flexibility for content creators and developers, enabling the display of various complex navigation menus and sub-menus.Implement flexible navigation menus and sub-menus in the AnQi CMS template

2025-11-09

How to set the SEO display rules for article, product, page titles and other content in AnQi CMS?

In website operation, the content title is like the facade of the website, it is not only the first impression seen by visitors, but also an important basis for search engines to understand the content of the page and judge its relevance.A meticulously optimized content title that can significantly improve the click-through rate (CTR) and ranking of the website.AnQiCMS (AnQiCMS) as a highly SEO-friendly content management system, has provided us with very flexible and powerful tools to finely set the SEO display rules for articles, products, pages, and other content. Next

2025-11-09

How does the custom content model of AnQi CMS affect the display of front-end data fields?

In website content management, flexibility is the key to improving efficiency and user experience.AnQiCMS (AnQiCMS) performs well in this aspect, with its custom content model feature being particularly powerful.It not only makes content management more organized, but also directly affects the way website front-end data is displayed, making it easy for the website to adapt to various content structures and business needs. ### Understanding Custom Content Model One of the core strengths of Anqi CMS lies in its "flexible content model".

2025-11-09

How to use the recommended attributes of Anqi CMS (such as headlines, sliders) to control the display of homepage content?

When building and maintaining a website, the homepage is undoubtedly the first stop for users to visit, and its way of displaying content directly affects user experience and information communication efficiency.A meticulously planned and flexible homepage layout that can effectively attract visitors, guide traffic, and highlight the core value of the website.AnQiCMS provides a series of powerful content recommendation features, allowing you to easily control the dynamic display of homepage content and meet various operational needs.Flexible use of AnQi CMS recommended attributes AnQi CMS in content management

2025-11-09

How to display filter conditions on the document list page of Anqi CMS and dynamically update results based on parameters?

In AnQi CMS, adding filtering conditions to the document list page and dynamically updating the results based on user selection is an important aspect of improving the discoverability and user experience of website content.This not only helps visitors quickly locate the content they are interested in, but also has a positive impact on SEO through a clear URL structure.Let's understand step by step how to implement this feature in Anqi CMS. ### Core Function: Content Model and Custom Fields are Basic Everything in Anqi CMS is built based on the "Content Model". The filtering function on the document list page

2025-11-09

How to display the links and titles of the previous and next documents in AnQi CMS?

How to easily display the link and title of the previous and next document in AnQi CMS?When browsing website articles, we often hope to smoothly jump from the current content to the previous or next related article. This seamless reading experience not only enhances user satisfaction but also has a positive effect on the overall structure of the website's content and SEO optimization.AnQi CMS is well-versed in this, providing content operators with an extremely convenient way to deploy such navigation functions with its flexible and powerful template engine.

2025-11-09

How to display related recommended documents on the document detail page of AnQi CMS and customize the recommendation logic?

After visitors have read an interesting document or viewed a product introduction on your website, if they can get more relevant recommendations in a timely manner, it will undoubtedly greatly enhance their visit experience, extend their stay time, and encourage them to explore more corners of the website.AnQi CMS knows this and provides flexible and diverse features to help you cleverly display related recommendations on the document detail page, and can customize the recommendation logic according to your operational strategy. We will delve into how to implement this feature in Anqi CMS in detail.###

2025-11-09

How to use Anqi CMS tags and filters to format date and timestamp display?

The timeliness and readability of website content largely depend on the accuracy and aesthetics of date and time information.AnQi CMS as an efficient content management system provides flexible tags and filters, helping us easily implement personalized display of dates and timestamps, making your website content more in line with user habits and enhancing the overall reading experience.This article will deeply explore how to巧妙运用these functions in Anqi CMS, converting raw time data into a clear and understandable display form.### Understand the Date and Time Data in Anqi CMS In Anqi CMS

2025-11-09