How to generate breadcrumb navigation path in AnQiCMS templates?

Calendar 👁️ 57

As an experienced security CMS website operator, I know the importance of a clear and efficient website navigation system for user experience and Search Engine Optimization (SEO).Breadcrumbs navigation is an important part of website auxiliary navigation, which can intuitively show the user's position on the website and provide a convenient return path.AnQi CMS with its flexible template engine makes it easy and efficient to generate breadcrumb navigation in website templates.

Generate breadcrumb navigation path in AnQiCMS template

Integrate breadcrumb navigation in AnQiCMS templates, mainly relying on built-inbreadcrumbLabel.This tag is designed to automatically generate the corresponding navigation path based on the structure of the current page (for example: Home > Category > Article), greatly simplifying the work of template developers.

To usebreadcrumbtags, you need to insert the following structure at the appropriate position in the template:

{% breadcrumb crumbs with index="首页" title=true %}
    <nav class="breadcrumb">
        <ul>
            {% for item in crumbs %}
                <li>
                    {% if not loop.last %}
                        <a href="{{ item.Link }}">{{ item.Name }}</a> &gt;
                    {% else %}
                        <span>{{ item.Name }}</span>
                    {% endif %}
                </li>
            {% endfor %}
        </ul>
    </nav>
{% endbreadcrumb %}

In this code block,breadcrumbThe tag will store the generated breadcrumb path in an array variable namedcrumbsThen, you can use theforLoop throughcrumbsarray to render each path segment (item)Link(link address) andName(Display Name).In general, to maintain the semantics of breadcrumb navigation, only the path segments that are not on the current page should be linked, and the path segments on the current page should be displayed as plain text.loop.lastDetermine whether it is the last element to control.

Detailed explanation of the breadcrumb tag parameters

breadcrumbThe tag provides several practical parameters, allowing you to flexibly configure according to the specific needs of the website:

indexParameter

This parameter is used to customize the display text of the 'home page' link in the breadcrumb navigation.By default, it will display as "Home".indexParameter to achieve.

For example, if you want to display the homepage as "My Blog":

{% breadcrumb crumbs with index="我的博客" %}
    {# ... 循环渲染 crumbs ... #}
{% endbreadcrumb %}

titleParameter

This parameter controls whether the current page title is displayed in the breadcrumb navigation of the document or single page detail page. It accepts three types of values:

  • title=trueThis is the default behavior. On the detail page (such as the article detail page), the last link of the breadcrumb will display the full title of the page.
  • title=falseIf set tofalseThis will not display the current page title in the breadcrumb on the detail page. This may help simplify the visual presentation in some designs, or when you want to manually control the display of the title.
  • title="自定义标题"You can directly pass a string, which will be displayed as the last link of the detail page breadcrumb, for exampletitle="文章详情"This provides greater flexibility for the display of the title.

For example, if you do not want to display the current title on the detail page:

{% breadcrumb crumbs with index="首页" title=false %}
    {# ... 循环渲染 crumbs ... #}
{% endbreadcrumb %}

Or if you want to display a general title:

{% breadcrumb crumbs with index="首页" title="阅读详情" %}
    {# ... 循环渲染 crumbs ... #}
{% endbreadcrumb %}

siteIdParameter

siteIdThe parameter is mainly used for multi-site management scenarios. If you have created multiple sites in the AnQiCMS backend and need to call breadcrumb data from other sites in a template of a particular site (this is not common because breadcrumbs should reflect the navigation structure of the current site), you can specifysiteIdTo implement. For single-site users, this parameter is usually not required.

Actual application examples and **practice

In actual template development, in order to maintain code neatness and maintainability, it is usually to store the breadcrumb navigation code snippet in a separate file, such as/template/您的模板目录/partial/breadcrumb.htmlThen in each page template that needs to display breadcrumbs, useincludetag to include it.

Example: inpartial/breadcrumb.htmldefine the breadcrumbs.

{# /template/您的模板目录/partial/breadcrumb.html #}
{% breadcrumb crumbs with index="首页" title=true %}
    <nav class="breadcrumb">
        <ol itemscope itemtype="https://schema.org/BreadcrumbList">
            {% for item in crumbs %}
                <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
                    {% if not loop.last %}
                        <a itemprop="item" href="{{ item.Link }}">
                            <span itemprop="name">{{ item.Name }}</span>
                        </a>
                        <meta itemprop="position" content="{{ loop.index }}" />
                    {% else %}
                        <span itemprop="name">{{ item.Name }}</span>
                        <meta itemprop="position" content="{{ loop.index }}" />
                    {% endif %}
                </li>
            {% endfor %}
        </ol>
    </nav>
{% endbreadcrumb %}

Here, Schema.org microdata tags have been added, which are very beneficial for search engines to understand the structure of websites and improve SEO performance.

Introduce breadcrumbs in the page template

For example, in your article detail pagearchive/detail.htmlIn it, you can introduce it like this:

{# /template/您的模板目录/archive/detail.html #}
{% extends 'base.html' %} {# 假设您有基础模板 #}

{% block content %}
    <div class="main-content">
        {% include 'partial/breadcrumb.html' %} {# 引入面包屑导航 #}
        <h1>{{ archive.Title }}</h1>
        <article>
            {# 文章内容 #}
            {{ archive.Content|safe }}
        </article>
    </div>
{% endblock %}

In this way, you can ensure that the breadcrumb navigation style of the entire website is consistent, and you only need to edit one piece of code when making changes.A unified breadcrumb style and accurate navigation path not only improves the user's browsing experience but also helps search engines better capture and understand the hierarchy of your website, thereby having a positive impact on SEO.

Frequently Asked Questions (FAQ)

1. How to modify the text of 'Home' in the breadcrumb navigation?

You can use it tobreadcrumblabel'sindexParameters to modify the "homepage" text. For example,{% breadcrumb crumbs with index="我的网站主页" %}The homepage will be displayed as "My website homepage."

2. Why is the article title not displayed in the breadcrumb of my article detail page?

This might be because you havetitlethe parameter tofalse. Please check yourbreadcrumbtag, make suretitlethe parameter totrue(default) or a custom string. For example:{% breadcrumb crumbs with title=true %}.

How to adjust the breadcrumb path style?

The breadcrumb path style is completely controlled by your CSS file. In the above example, we used<nav class="breadcrumb">and<ul><li>the structure. You can specify it in the style sheet of your website..breadcrumb/ul/liandaDefine the styles for elements to match your website design.

Related articles

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

Hello, I am the familiar Anqi CMS website operation veteran that you know.Navigation menus are of great importance in daily website maintenance and content optimization, as they are not only guides for users to browse the website but also crucial for search engines to understand the website structure.Today, let's delve into how to build a flexible and efficient multi-level navigation menu in the AnQiCMS template.

2025-11-06

How to dynamically set the content of the `<title>`, `<meta keywords>`, and `<meta description>` tags for AnQiCMS pages?

As an experienced security CMS website operator, I know that website SEO optimization is the core work to attract and retain users, and to enhance the visibility of the website.It is crucial to accurately set the <title>, <meta keywords>, and <meta description> tags for each page (collectively known as TDK, i.e., Title, Description, Keywords).The AnQi CMS was designed with SEO-friendliness in mind from the outset

2025-11-06

How to call the contact information set in the background of AnQiCMS template?

As an experienced senior personnel proficient in AnQi CMS content operation, I am well aware of the importance of efficient website information management in attracting and retaining users.Especially contact information such as this basic yet crucial information, its unified management and flexible access are the foundation for improving operational efficiency and ensuring the accuracy of information.Below, I will introduce how to call the contact information set in the background of the AnQiCMS template.

2025-11-06

How to get and display the website name and logo in AnQiCMS template?

As an experienced CMS website operation personnel of an enterprise, I am well aware of the importance of effectively displaying brand information in templates for user experience and brand recognition.The following article will provide a detailed guide on how to obtain and display the website name and logo in the AnQiCMS template.In AnQiCMS template, a practical guide to obtaining and displaying the website name and LogoThe website's name and logo are the core visual elements of the brand

2025-11-06

How to list category information in AnQiCMS templates by module or parent relationship?

A detailed guide to listing category information by module or parent relationship in AnQiCMS templates As an experienced AnQiCMS website operator, I know the importance of content organization.A clear, easy-to-navigate classification system not only improves user experience, but is also the foundation of SEO optimization.AnQi CMS, with its flexible content model and powerful template tag system, provides us with multiple ways to display category information in website templates according to module or parent-child relationship.This article will delve into how to make use of these features to build an efficient classification list.###

2025-11-06

How to get and display detailed information of a specified category in AnQiCMS template?

As an experienced CMS website operation personnel of an enterprise, I know that it is crucial to display content efficiently and accurately in templates for the attractiveness and SEO performance of the website.Category information is the core of website architecture, able to accurately obtain and present on the front-end page, not only improving user experience, but also providing a clear structure for search engine crawling.Today, let's discuss in detail how to obtain and display detailed information of a specified category in the Anqi CMS template.

2025-11-06

How to list all or specified types of single pages in AnQiCMS template?

Managing and displaying single pages in AnQiCMS is a common requirement for website operation, especially for static content such as 'About Us', 'Contact Information', and 'Terms of Service'.As an experienced AnQiCMS operator, I know that efficient use of template tags can greatly enhance the flexibility of content publishing and the maintenance efficiency of the website.This article will detail how to list all or specified types of single pages in the AnQiCMS template.### Understanding the Single Page Mechanism of AnQiCMS In AnQiCMS, a single page (Single

2025-11-06

How to display the detailed content of a specified single page in AnQiCMS template?

In AnQiCMS website operation, the Single Page (Page) feature is a very practical module, which allows us to create and manage static pages independent of dynamic content such as articles or products, such as "About Us", "Contact Information", or "Service Introduction" and so on.These pages usually contain relatively fixed and important information, which needs to be presented to visitors in a clear and direct manner.As a senior operator of AnQiCMS, I know how to effectively use the template mechanism to accurately control the display of these single pages to meet the diverse design and content needs.

2025-11-06