How to use breadcrumb navigation tags in AnQiCMS templates to enhance user experience?

Calendar 👁️ 68

In modern web design, user experience (UX) and search engine optimization (SEO) are the two pillars of success.A clear and intuitive navigation system not only guides users to find the information they need easily, but also helps search engines better understand the structure of the website.Among them, Breadcrumb Navigation is an effective tool to improve these two aspects.For AnQiCMS users, it is easy to integrate high-quality breadcrumb navigation into the website by reasonably utilizing its powerful template tag features.

What is breadcrumb navigation and why is it important?

Imagine exploring a vast forest, occasionally looking back at the path you've taken, it always brings you a sense of peace.Breadcrumbs navigation is like a roadmap in your website, showing the user's current page position in the entire website hierarchy. For example:首页 > 产品中心 > 电子设备 > 智能手机.

The importance is reflected in:

  1. Improve user experience:The user can clearly understand where they are and quickly navigate back to the parent page, reducing the feeling of being lost and improving navigation efficiency.Especially for websites with deep hierarchies or rich content, the breadcrumb navigation plays a more prominent role.
  2. Optimize SEO:The search engine understands the hierarchical structure of the website through breadcrumb navigation, which helps in crawling and indexing the website content.At the same time, the internal links within the breadcrumb also build natural internal links, which help in weight transfer and keyword ranking.AnQiCMS has taken full consideration of SEO-friendliness in its design, breadcrumb navigation is an important part of it.

Breadcrumbs navigation label in AnQiCMS

AnQiCMS provides a dedicated template tagbreadcrumbAllow you to easily call and render breadcrumb navigation in the template.This tag can automatically generate an array containing path information based on the current page's URL and content hierarchy for display on the front end.

The basic usage is very concise and clear, it is usually defined in a variable, for examplecrumbs:

{% breadcrumb crumbs %}
    {# 在这里通过循环渲染面包屑路径 #}
{% endbreadcrumb %}

crumbsThe variable will be an array object, where each element represents a link in the navigation path, including the link name and address.

Core parameter details

breadcrumbThe tag built-in some practical parameters, allowing you to flexibly configure according to the specific needs of the website to further improve the user experience:

  1. indexParameter: Customize the starting pointBreadcrumb navigation usually starts from the homepage of a website.indexParameters allow you to customize the display name of this starting point. By default, it is displayed as 'Home'.

    • Default usage: {% breadcrumb crumbs %}(Home page is displayed at the start)
    • Custom name:If you want to display 'Website Home Page' or 'My Blog', you can set it like this:
      
      {% breadcrumb crumbs with index="网站首页" %}
      {# 渲染面包屑 #}
      {% endbreadcrumb %}
      
  2. titleParameter: Controls the display of the current page titleThe last element of the breadcrumb navigation is usually the title of the current page, it should not contain a link (because the user is already on this page).titleThe parameter is used to control the display of this element.

    • Default usage: title=true. AnQiCMS will try to get the title of the current page and display it as the last element.
    • Do not display the title:If you do not want the breadcrumb to display the title of the current page, you can set it totitle=false:
      
      {% breadcrumb crumbs with title=false %}
      {# 渲染面包屑,不包含当前页标题 #}
      {% endbreadcrumb %}
      
    • Custom title:Sometimes, the current page title may be too long or not suitable for direct display in the breadcrumb, and you can provide a custom string as the display content of the last element:
      
      {% breadcrumb crumbs with title="详情页" %}
      {# 渲染面包屑,最后一个元素显示“详情页” #}
      {% endbreadcrumb %}
      
  3. siteIdParameter: Data call under multiple sites (advanced usage)AnQiCMS supports multi-site management, if you have created multiple sites in the background and need to call the breadcrumb data of another site in the template of a site, you can usesiteIdThe parameter specifies the target site ID. For single-site users, this parameter is usually not required.

    • Example: {% breadcrumb crumbs with siteId="2" %}

How to integrate breadcrumbs into your template?

In actual practice, you usually find the common header file of the website template (such asbash.htmlorheader.htmlIf you have usedextendsorinclude) or place a breadcrumb navigation at the top of the content area. The typical HTML structure uses an unordered list<ul>or an ordered list<ol>combinedforto loop throughcrumbsEach path element in the variable.

The following is a complete example of integrating breadcrumb navigation into the AnQiCMS template:

<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        {% breadcrumb crumbs with index="网站首页" title=true %}
            {% for item in crumbs %}
                <li class="breadcrumb-item {% if loop.last %}active{% endif %}">
                    {# 如果不是最后一个元素,则添加链接 #}
                    {% if not loop.last %}
                        <a href="{{ item.Link }}">{{ item.Name }}</a>
                    {% else %}
                        {# 最后一个元素只显示文本,不带链接 #}
                        {{ item.Name }}
                    {% endif %}
                </li>
            {% endfor %}
        {% endbreadcrumb %}
    </ol>
</nav>

Code analysis:

  • <nav aria-label="breadcrumb">Using HTML5'snavTags andaria-labelattribute to enhance semantics and accessibility.
  • <ol class="breadcrumb">: Use an ordered listolIt indicates the order of the navigation path and adds a CSS classbreadcrumbfor styling.
  • {% breadcrumb crumbs with index="网站首页" title=true %}: Call the breadcrumb tag, and store the returned path incrumbsVariable within, and set the homepage name to "website homepage", the current page title is displayed automatically.
  • {% for item in crumbs %}:TraversecrumbsEach breadcrumb item in the array.
  • loop.lastThis is a special loop variable used to determine whether the current loop is the last element.
  • {% if not loop.last %}If it is not the last element, render a<a>tag to make it clickable.
  • {{ item.Link }}and{{ item.Name }}:Output the link address and display name of the breadcrumb item separately.
  • {% else %}{{ item.Name }}{% endif %}:If it is the last element (i.e., the current page), only the name is displayed without adding a link.
  • {% endif %}: End condition judgment.
  • </li>:End the list item.
  • {% endfor %}Loop ends.
  • {% endbreadcrumb %}Breadcrumb tag call ends.

After rendering, this code may output something similar.网站首页 > 产品中心 > 电子设备 > 智能手机This structure, and all levels except 'Smartphone' are clickable.You can combine CSS styles to make it look beautiful and consistent with your website theme.

Summary

In AnQiCMS, by utilizingbreadcrumbTo create breadcrumb navigation with template tags is a simple and efficient process. Through reasonable configurationindexandtitleParameters, you can easily provide a clear navigation path for the website, which not only greatly improves the user's browsing experience, but also builds a friendly website structure for search engines, thus achieving better results in both user experience and SEO.Integrating this feature into your website template is undoubtedly an important step to optimizing website quality.


Frequently Asked Questions (FAQ)

Q1: Why doesn't my breadcrumb navigation show the title of the current page?

A1: This is usually because you arebreadcrumbThe tag is set.title=falseortitleThe value is an empty string. Please check your template code, make suretitlethe parameter totrue, or set it to the custom title string you want to display, such as{% breadcrumb crumbs with title=true %}or{% breadcrumb crumbs with title="阅读正文" %}.

Q2: How to customize the breadcrumb navigation style? For example, how to modify the separator style or text color?

A2: Breadcrumb navigation style is usually controlled by CSS. AnQiCMS'sbreadcrumbTags generate standard HTML structures (such asolandli),You can add CSS classes to these HTML elements (such as in the example shown),then define the corresponding styles in your CSS file. For example,You can usebreadcrumbandbreadcrumb-item),Then define the corresponding styles in your CSS file. For example,You can use::afterThe pseudo-element to add a custom separator:

.breadcrumb-item + .breadcrumb-item::before {
    content: ">"; /* 可以是任意字符或图标 */
    padding: 0 5px;
    color: #6c757d;
}
.breadcrumb-item a {
    color: #007bff;
    text-decoration: none;
}
.breadcrumb-item.active {
    color: #6c757d;
}

Q3: Can breadcrumb navigation automatically identify all types of pages? Such as tabs or search result pages?

A3: breadcrumbThe tag is mainly generated automatically based on the content hierarchy of the website (such as categories, documents, single pages, etc.).For some special dynamic pages, such as search result pages or some highly customized tab pages, the hierarchy may not be as clear as that of conventional content pages.AnQiCMS will strive to provide a path based on URL structure or built-in logic.If the breadcrumb display of a specific page does not meet expectations, you may need to manually adjust according to the specific URL rules of that page

Related articles

How to configure AnQiCMS's pseudo-static rules to achieve personalized URL display?

## Optimize URL structure, create personalized website links: AnQiCMS Static Rule Configuration Guide In website operations, URL (Uniform Resource Locator) is not only the address of content, but also an important part of Search Engine Optimization (SEO) and User Experience (UX).A clear, meaningful, and easy-to-remember URL structure that can effectively improve a website's ranking in search engines, as well as allow visitors to understand the page content more intuitively.

2025-11-07

How does AnQiCMS automatically handle image thumbnails to optimize the display speed of website content?

In today's fast-paced online world, the speed of displaying website content, especially the speed of image loading, directly affects user experience, website bounce rate, and even search engine rankings.Large images are often the culprits that slow down website speed, but without them, the content can become dull and boring.How can one have the cake and eat it too, showing high-quality images while ensuring the website content loads quickly?

2025-11-07

How to implement nested list display of multi-level categories in AnQiCMS templates?

The navigation structure of the website is the core of user experience, a clear and organized multi-level classification list can not only help users quickly find the content they need, but also effectively improve the website's SEO performance.In AnQiCMS, with its flexible template tag system, achieving the intuitive and efficient display of nested list categories becomes straightforward. ### Understanding AnQiCMS's Classification Structure In the AnQiCMS admin interface, you will find that the classification function allows you to create classifications with hierarchical relationships.This means you can write an article for

2025-11-07

How to filter and sort articles by category ID and recommendation attributes when displaying the article list in AnQiCMS?

How to effectively organize and present article lists in a content management system is a key factor that directly affects user experience and website information architecture.AnQiCMS provides a flexible and powerful template tag that allows us to refine and sort articles based on category ID and recommended attributes, thereby achieving accurate content placement and optimized display. ### Understanding the `archiveList` article list tag The display of AnQiCMS article lists depends on the `archiveList` template tag.It is like a universal content query tool

2025-11-07

How does AnQiCMS ensure that uploaded image resources are displayed correctly on the front end and protected by copyright?

## Security CMS: The Front-end Display and Copyright Protection of Image Resources High-quality image resources are not only the key to attracting users and enhancing the value of content in modern website operations, but also crucial for smooth display on the front-end and copyright protection behind it.AnQi CMS deeply understands this, from image upload to frontend display, to copyright protection, it provides a considerate and efficient solution set, allowing us to focus on the content itself without worrying about the technical details.

2025-11-07

How to call and display the contact information of the website in AnQiCMS template?

Easily call and display the website contact information in AnQiCMS templates AnQiCMS is an efficient and flexible content management system dedicated to helping businesses and content operation teams easily manage website content.The powerful template engine support allows website developers to display data configured on the backend in a straightforward manner.Today, let's delve into how to conveniently call and display the various contact information of the website in the AnQiCMS template, so that your visitors can get in touch with you as soon as possible.

2025-11-07

How to set the TDK (title, keywords, description) of the homepage of AnQiCMS to optimize search engine display?

## AnQiCMS Home Page TDK Optimization Guide: The Key Step to Enhancing Search Engine Visibility In today's increasingly fierce internet competition, it is the goal of every website operator to make their website stand out in search engines and gain more organic traffic. "TDK" - that is, Title, Keywords, and Description - is the foundation of website SEO and an important basis for search engines to grab and judge the main theme of the website content.

2025-11-07

How to create and manage the website navigation menu in AnQiCMS and control its display hierarchy?

During the operation of a website, a clear and efficient navigation menu is the core of user experience.A well-designed navigation can not only help visitors quickly find the content they need, but also effectively guide search engines to crawl, improving the overall SEO performance of the website.In AnQiCMS, creating and managing website navigation menus, and controlling their display levels, is a straightforward and powerful process.

2025-11-07