How to correctly display the breadcrumb navigation path on the content page?

Calendar 👁️ 71

Breadcrumb Navigation is a common and practical navigation method on websites, which can clearly show the current position of the user in the website hierarchy, just like breadcrumbs scattered in the forest guiding the way home.For users, breadcrumb navigation not only helps them quickly understand the hierarchical relationship of the current page within the entire website, but also facilitates their ability to backtrack to higher-level pages, greatly enhancing the user experience of the website.At the same time, a clear breadcrumb path is also helpful for search engines to better understand the structure of the website, which may bring better crawling and ranking effects for search engine optimization (SEO).

AnQi CMS is an efficient content management system that fully considers the importance of this feature, and is built-in with convenient breadcrumb navigation tags, allowing website operators to easily display and manage these navigation paths on content pages.

Add breadcrumb navigation on the content page

To display the breadcrumb navigation correctly on the content page of Anqi CMS, we first need to use the built-in features in the template file.breadcrumbLabel. Usually, to maintain the cleanliness and reusability of the template, we will place the breadcrumb navigation code snippet in a separate template file (such aspartial/breadcrumb.html), and then referenced byincludeTag it to include in the website's universal header file (such asbash.html) or in the specific content page template.

Here is an example of a basic breadcrumb navigation implementation:

First, in the directory of your templatepartialcreate a file named,breadcrumb.htmlfile (if it does not exist).

{# partial/breadcrumb.html #}
<nav class="breadcrumb-nav" aria-label="breadcrumb">
    <ol class="breadcrumb-list">
        {% breadcrumb crumbs %}
            {% for item in crumbs %}
                <li class="breadcrumb-item">
                    {% if forloop.Last %} {# 判断是否为最后一个面包屑项 #}
                        <span aria-current="page">{{item.Name}}</span>
                    {% else %}
                        <a href="{{item.Link}}">{{item.Name}}</a>
                    {% endif %}
                </li>
            {% endfor %}
        {% endbreadcrumb %}
    </ol>
</nav>

In this code block:

  • {% breadcrumb crumbs %}It is a core tag provided by AnQi CMS, which automatically generates an array containing path information based on the current page URL and the structure of the website, and assigns it tocrumbsVariable.
  • {% for item in crumbs %}Loop throughcrumbsEach path segment in the array.
  • item.NameRepresents the display name of the path segment (e.g., "Home", "Article Category", "Article Title").
  • item.LinkIndicates the URL address corresponding to the path segment.
  • forloop.LastIs an embedded loop variable used to determine whether the current loop item is the last one. Typically, the last breadcrumb item (i.e., the current page) should not be a link, but simply text and containaria-current="page"Accessibility properties to enhance.

Next, you can add it in your website's common template files (such as)bash.html) in, on<body>The appropriate location (usually at the top of the page content area, below the main navigation) to introduce this breadcrumb navigation snippet:

{# bash.html 或您希望显示面包屑导航的任何模板文件 #}
...
<body>
    {# 网站头部内容,如Logo、主导航等 #}
    {% include "partial/header.html" %}

    <main>
        {# 引入面包屑导航 #}
        {% include "partial/breadcrumb.html" %}

        {# 当前页面主要内容区域 #}
        {% block content %}{% endblock %}
    </main>

    {# 网站底部内容 #}
    {% include "partial/footer.html" %}
</body>
...

After completing these steps, when you visit any content page on the website, such as article detail pages, product detail pages, category list pages, or single pages, the system will automatically generate and display the corresponding breadcrumb navigation path based on the current page location.

Customize the display of the breadcrumb navigation.

Of Security CMSbreadcrumbThe tag also provides some parameters to allow for more fine-grained control over the display of breadcrumb navigation:

  1. Customize the home page name (index)By default, the first item of the breadcrumb navigation is 'Home'. If you want to display it as another name, such as 'My Blog' or 'Website Homepage', you can useindexSet the parameters.

    {% breadcrumb crumbs with index="我的博客" %}
        {# ... 循环显示 crumbs ... #}
    {% endbreadcrumb %}
    
  2. Control document title display (title)In the document detail page (such as article, product page), the last item of the breadcrumb navigation is usually the title of the document. You can usetitleParameters to control its display mode:

    • title=true(Default): Display the full document title.
    • title=false: Do not display the document title, the breadcrumb path stops at the current category.
    • title="自定义标题": Display the custom string you specified as the last bread item.
    {# 在文章详情页,如果不想显示具体文章标题,只到分类层级 #}
    {% breadcrumb crumbs with title=false %}
        {# ... 循环显示 crumbs ... #}
    {% endbreadcrumb %}
    
    {# 或者,将文章标题统一显示为“文章详情” #}
    {% breadcrumb crumbs with title="文章详情" %}
        {# ... 循环显示 crumbs ... #}
    {% endbreadcrumb %}
    

Use these parameters together. You can flexibly adjust the display effect of the breadcrumb navigation according to the design of the website and the needs of user experience.

Practical suggestions for breadcrumb navigation.

  • Semantic HTML:Use<nav>/<ol>/<li>and<a>Use semantic tags to build breadcrumb navigation, which helps improve website accessibility and SEO friendliness.
  • Clear styles:Although breadcrumb navigation is more functional than visual, it still needs to be styled appropriately with CSS to maintain consistency with the overall website style and make it easy for users to identify and click.Ensure that the link has enough click area, and the current page (the last item) can be clearly identified through the style.
  • Adapt for mobile:On mobile devices, breadcrumb navigation may appear lengthy due to space constraints.Consider using a responsive design, such as displaying only the most recent levels, or collapsing the breadcrumbs into a clickable 'back' button.
  • Hierarchical logic:Breadcrumbs should strictly follow the actual hierarchy of the website, do not skip levels or create logically inconsistent paths, as this will confuse users.

Provided by Anqi CMSbreadcrumbTags with flexible parameters, you can easily build user-friendly and SEO-optimized breadcrumb navigation for your website, enhancing the overall quality of the site.


Frequently Asked Questions (FAQ)

1. Why is my breadcrumb navigation not displaying?

If the breadcrumb navigation is not displaying, please check the following points first:

  • Did you correctly introduce it in the template?breadcrumb.html?Confirm that your main template file (such asbash.htmlor page detail template) is being used{% include "partial/breadcrumb.html" %}.
  • breadcrumb.htmlDoes the file exist in the correct path?Ensure that the file is indeed intemplateUnder the directorypartialin the folder.
  • Does the current page have a clear hierarchy structure?Breadcrumbs navigation is automatically generated based on the page classification, model, or parent-child relationship of a single page.If the current page is the website's homepage or does not have a clear category, the breadcrumb may only display 'Homepage' or be empty.Please check if the content classification settings are correct.
  • Is the website cache cleared?After modifying the template file, sometimes you need to clear the website cache to see the latest effect. You can find the "Update Cache" feature in the AnQi CMS backend to perform the operation.

How to exclude a certain level in the breadcrumb navigation, such as not displaying the intermediate level of 'Product Category'?

Of Security CMSbreadcrumbThe tag does not directly provide the functionality to exclude specific levels. However, you can do so by iterating in a loop{% for item in crumbs %}Add conditional judgment to implement custom filtering logic. For example, if you want to exclude the level named "Product Category", you can modify it as followsbreadcrumb.html:

<nav class="breadcrumb-nav" aria-label="breadcrumb">
    <ol class="breadcrumb-list">
        {% breadcrumb crumbs %}
            {% for item in crumbs %}
                {# 假设 item.Name 不会是空字符串 #}
                {% if item.Name != "产品分类" %}
                    <li class="breadcrumb-item">
                        {% if forloop.Last %}
                            <span aria-current="page">{{item.Name}}</span>
                        {% else %}
                            <a href="{{item.Link}}">{{item.Name}}</a>
                        {% endif %}
                    </li>
                {% endif %}
            {% endfor %}
        {% endbreadcrumb %}
    </ol>
</nav>

Please note that this method is based on the name of the breadcrumb item, and if the name may change or if there are multiple similar names, you need to adjust the judgment logic.

How to change the breadcrumb navigation style?

The visual style of the breadcrumb navigation is entirely dependent on your website's CSS file. The Anqi CMS providesbreadcrumbThe tag is responsible for outputting the HTML structure of the navigation path, and for color, font, size, spacing, and background, etc., you need to implement them by writing or modifying CSS code.

You can use similarbreadcrumb-nav/breadcrumb-list/breadcrumb-itemandbreadcrumb-item aCSS selectors to set styles specifically. For example:

`css

Related articles

How to build and display multi-level navigation menus on a website?

The website navigation menu is a guidepost for users to browse the website content, a well-designed multi-level navigation system can significantly improve user experience, and help visitors quickly locate the required information.A clear, intuitive, and easy-to-use navigation is a key element for the success of a corporate website, product showcase page, or content portal.AnQi CMS is a comprehensive and flexible content management system that provides intuitive backend settings and powerful template tags, allowing you to easily build and manage multi-level navigation menus that meet various needs.

2025-11-08

How to dynamically set the page TDK information to optimize SEO display?

In today's digital age, Search Engine Optimization (SEO) is crucial for the success of any website, and the TDK information - that is, the page's Title (title), Description (description), and Keywords (keywords) - is a key factor for search engines to understand the content of the page and determine its ranking.If this information is set properly, it can not only improve the visibility of the website in search results, but also attract users to click and bring high-quality traffic. Manually setting TDK for each page is not only time-consuming and labor-intensive, but also prone to omission.Fortunately

2025-11-08

How to display a company's contact information on the front-end page, including custom fields?

It is crucial to clearly and conveniently display a company's contact information in website operation.It not only enhances visitors' trust in the website, facilitates potential customers to consult, but is also the cornerstone of business transformation.AnQiCMS (AnQiCMS) understands this and provides powerful and flexible features that allow you to easily manage and display various corporate contact information on the website front end, including custom fields.

2025-11-08

How to display the system configured name and Logo on the website homepage?

The website's name and logo are the foundation of the brand image, they can not only quickly convey the identity of the website, but also enhance the user's sense of trust and recognition.In AnQiCMS, presenting these important brand elements on the homepage is a direct and flexible task.AnQiCMS provides an intuitive backend setup and powerful template tag features, making this task very simple.### Backend Configuration: Unified Brand Information Management Firstly, all information that needs to be displayed on the website front end must be managed uniformly in the AnQiCMS backend

2025-11-08

How to display a category list based on content model or parent-child relationship?

AnQi CMS is an efficient enterprise-level content management system that provides great flexibility in content organization and display.For many websites, how to display a category list based on different content models or the hierarchical relationship of categories is a very common and important need.This concerns not only the organization structure of the website content, but also directly affects the user experience and SEO effect.In Anqi CMS, implementing such a display is not complicated.The built-in template tags provide us with powerful functions, allowing us to easily control the output of the classification list

2025-11-08

How to retrieve and display detailed information of a specific category (such as description, Banner image)?

In Anqi CMS, it is crucial to flexibly obtain and display detailed information about categories, such as descriptions, Banner images, or thumbnails, which is essential for building a website rich in content and visually appealing.Whether it is necessary to display a brief introduction on the category list page or to reference the promotional picture of a specific category on a specific page, Anqi CMS provides intuitive and powerful template tags to help you meet these needs. To get detailed information about the category, we mainly rely on the `categoryDetail` template tag.This tag is specifically designed to extract data for each category

2025-11-08

How to display all or part of a single-page list on a website?

In website operations, we often need to display some independent, fixed-content pages, such as 'About Us', 'Contact Information', or some policy descriptions, etc.In Anqi CMS, these are called "single pages". Effective management and presentation of these single pages not only makes the website structure clearer but also enhances the user experience.Next, we will discuss how to flexibly display all or part of a single-page list on a website.### **Understanding the Creation and Management of Single Pages (Backend Operations)** Before Starting the Frontend Display

2025-11-08

How to get and display all the content and associated images of a specific single page?

In Anqi CMS, a single page is an important part of the website content structure, such as "About Us", "Contact Information", and so on.Effectively acquire and display all the content of these single pages and associated images, which is crucial for the communication and visual expression of the website.Aanqi CMS provides an intuitive backend management and flexible template tags, making this process very convenient. ### Easily set up single page content and images in the background First, we need to create and edit single page content in the Anqi CMS backend management system. This is usually performed under the 'Page Resources' section in the 'Page Management' module

2025-11-08