How to correctly generate and display breadcrumb navigation on a page?

Calendar 👁️ 53

As a senior CMS website operator, I am very clear about the importance of breadcrumb navigation in improving user experience and website SEO.It not only helps visitors clearly understand their position on the website, but also guides search engines to better understand the website's hierarchy structure.In AnQi CMS, correctly generating and displaying breadcrumb navigation is a fundamental and important content management task.

Generating and displaying breadcrumb navigation in Anqi CMS

In AnQi CMS, generating and displaying breadcrumb navigation mainly relies on built-inbreadcrumbTemplate tag. This tag is designed to be very flexible, allowing us to customize the display of breadcrumbs according to different page requirements.Using this tag correctly ensures that every page of the website has clear and consistent navigation paths.

basic breadcrumb navigation implementation

To generate a basic breadcrumb navigation, we first need to include it in the template filebreadcrumbThe tag returns an array object containing all the stages in the navigation path, which we usually namecrumbsThen, by traversing thiscrumbsAn array can sequentially display each navigation link and its name.

For example, in a common page template, we can organize the breadcrumb navigation code like this:

<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        {% breadcrumb crumbs %}
        {% for item in crumbs %}
            {% if forloop.Last %}
                <li class="breadcrumb-item active" aria-current="page">{{item.Name}}</li>
            {% else %}
                <li class="breadcrumb-item"><a href="{{item.Link}}">{{item.Name}}</a></li>
            {% endif %}
        {% endfor %}
        {% endbreadcrumb %}
    </ol>
</nav>

This code first defines anavelement to wrap the breadcrumbs, and usesola list to present the hierarchical structure.breadcrumbthe tag to assign the generated navigation path tocrumbsthe variable, then throughforLoop throughcrumbseachitem. EachitemContainsName(link name) andLinkTwo fields such as (link address). We judgeforloop.LastTo determine whether the current item is the last one (i.e., the current page) so as to provide different styles andaria-currentAttribute, this helps to improve accessibility.

In most cases, in order to keep the code tidy and reusable, we will store this breadcrumb navigation code snippet inpartial/in the directory, for examplepartial/breadcrumb.htmlThen proceed in the page template where breadcrumbs need to be displayed{% include "partial/breadcrumb.html" %}to refer to.

Customize the display options of breadcrumb navigation

breadcrumbTags provide several parameters to further customize the behavior and display content of breadcrumb navigation.

Customizing the homepage name is a common requirement. By default, the first link name in the breadcrumb is 'Home'.If we need to change it to 'My Blog' or 'Homepage', we can useindexSet the parameters.

For example, change the name of the home page to "My Website":

{% breadcrumb crumbs with index="我的网站" %}
    {# ... 循环遍历 crumbs 的代码 ... #}
{% endbreadcrumb %}

The control of displaying the current page title is also an important feature.In some cases, we may not want the last item in the breadcrumb (i.e., the title of the current page) to be too long, or even not displayed at all.titleParameters can help us achieve this goal.

If you want the breadcrumbs not to display the title of the current page, you can settitlethe parameter tofalse:

{% breadcrumb crumbs with index="我的网站" title=false %}
    {# ... 循环遍历 crumbs 的代码,注意最后一项的 item.Name 将会是空或上级分类名 ... #}
{% endbreadcrumb %}

or, if you need to display the title of the current page as specific text, you can directly settitlethe parameter to this text, for example "Article Details":

{% breadcrumb crumbs with index="我的网站" title="文章详情" %}
    {# ... 循环遍历 crumbs 的代码,此时最后一项的 item.Name 将会是“文章详情” ... #}
{% endbreadcrumb %}

These flexible parameters make it possible for breadcrumb navigation to adapt to the needs of different page types and design styles, whether it is an article detail page, a product list page, or a single page, it can present the navigation path that best meets the user's expectations.

**Practical Recommendations and Optimization**

When implementing breadcrumb navigation in Anqi CMS, it is recommended to always place it at the top of the page content, just below the main navigation.This not only conforms to the user's visual habits, but also allows search engines to quickly identify the hierarchy of the page.

From a code perspective, using semantic HTML elements like<nav>and<ol>Build breadcrumb navigation and配合 appropriate CSS styles, it can ensure that it is visually beautiful and structurally clear.The multi-site management feature of AnQi CMS also means that we can specify specific breadcrumb configurations for different sites or different language versions to ensure consistency of global content and localization.If you need to call data from other sites,siteIdParameters can be useful, but are usually not a concern in single-site operations.

By following these practices, the operation staff of Anqi CMS can easily create breadcrumbs that are beneficial for user navigation and friendly to search engines, thus improving the overall performance of the website.

Frequently Asked Questions

What are the aspects in which breadcrumb navigation is important for a website?

Breadcrumbs navigation is crucial for the operation of a website. It can significantly improve user experience, allowing visitors to clearly know their position in the website structure at any time, and conveniently return to the upper-level page, reducing a sense of confusion.From an SEO perspective, breadcrumbs provide an additional internal link structure, which helps search engine spiders understand the hierarchy and content relevance of a website, thereby improving the page crawling efficiency and ranking.

Can I customize the style of the breadcrumb navigation?

Anqi CMS allows you to fully customize the style of the breadcrumb navigation.breadcrumbTags are only responsible for outputting structured navigation data, you can use HTML and CSS to design its appearance around this data. In the above example, we used<nav>and<ol>element was addedbreadcrumbandbreadcrumb-itemClass names, you can define the styles of these classes according to your design needs in the CSS file, such as adjusting the font, color, background, spacing, and separators.

How do I prevent the full title of the current page from being displayed in the breadcrumbs?

In AnQi CMS, you canbreadcrumblabel'stitleParameters to control the display of the current page title. If you do not want to display the full title of the current page, you cantitlethe parameter tofalseSuch that the last item of the breadcrumb will not include the title text of the current page. You can also set it to a short custom string, such astitle="详情页"In order to represent the current page more concisely.

Related articles

How to display a website navigation menu and support multi-level dropdown navigation?

As an experienced CMS website operation personnel of an enterprise, I know that a well-organized and easy-to-use navigation menu is crucial for the website user experience and content discovery.AnQi CMS provides a powerful and flexible navigation management function, which can help us easily set up the main menu of the website and also support multi-level dropdown navigation to meet the needs of complex website structures. ### Backend Navigation Configuration: Build Menu Structure The setting of the navigation menu in AnQi CMS starts from the backend management interface.

2025-11-06

How to dynamically set and call the SEO title, keywords, and description (TDK) of the current page in the template?

As an experienced CMS website operation personnel in a cybersecurity company, I am well aware that high-quality content and excellent search engine optimization (SEO) are the foundation of a website's success.Among them, the SEO title (Title), keywords (Keywords), and description (Description) of the page, abbreviated as TDK, play a vital role.They are not only the key for search engines to understand the content of a page, but also an important factor in attracting users to click.In Anqi CMS, we have flexible and powerful mechanisms to dynamically set and call these TDK information

2025-11-06

How to obtain and display the contact information, phone number, email, WeChat, and other contact methods set in the background?

Hello, as an experienced CMS operation person in the security industry, I know that clear and convenient contact information on the website is crucial for user experience and business conversion.Today, let's discuss in detail how to configure contact information in the Anqi CMS backend and display it flexibly and accurately on various positions of the website front-end. Configure website contact information: Back-end operation guide Managing website contact information in AnQi CMS is an intuitive and powerful process.First, we need to enter the background management interface for configuration.

2025-11-06

How to call and display the name, Logo, and other system global configuration information in AnQi CMS template?

As an experienced security CMS website operations personnel, I am well aware of the importance of the global configuration information of the website, such as the website name and logo, for the unified display of the brand image and user recognition.In AnQi CMS, these core information is unifiedly managed, and through a concise and efficient template tag mechanism, it allows operators to easily call and display on various pages of the website. ### Management of website global configuration information in AnQi CMS AnQi CMS centralizes the global configuration information of the website in the "Global Function Settings" module of the background.

2025-11-06

How to get the classification list under a specific content model (such as articles, products)?

As an experienced CMS website operation personnel for Anqi, I know the importance of content organization and user experience for the success of the website.Accurately display content categories, not only can help users quickly find the information they are interested in, but also improve the overall SEO performance of the website.Today, we will delve into how to obtain the category list under specific content models (such as articles, products) in AnQiCMS, which is crucial for building clear website navigation, content aggregation modules, and special pages.

2025-11-06

How to retrieve detailed information for a specified category, such as the category name, description, and link?

As an experienced website content expert in AnQiCMS (AnQiCMS) operation, I fully understand the importance of classification information in building website structure and improving user experience.The Anqi CMS, with its intuitive and powerful template tag system, makes it exceptionally easy to obtain and display detailed information about categories.In order to optimize navigation, enrich page content, or improve SEO effect, accurately obtaining the category name, description, and link is an indispensable part of our daily operation.

2025-11-06

How to get the list of all single-page lists of a website?

As an experienced CMS website operation personnel of an enterprise, I know the importance of acquiring and managing website content, especially for single pages carrying core information such as 'About Us', 'Contact Information', or 'Terms of Service'.In AnQi CMS, the system provides an efficient and flexible way to obtain the list of these single pages, so that we can integrate them into website navigation, site map, or other display locations.

2025-11-06

How to get and display the title, content, and link of a specific single-page?

As an experienced CMS website operation person, I know that content is the soul of the website, and how to efficiently and accurately display content is a crucial link in our daily work.In Anqi CMS, a single page usually carries the core information of the company introduction, contact information, service description, etc., and its content often needs to be specifically retrieved and displayed in various corners of the website.Today, let's discuss in detail how to obtain and display the title, content, and link of a specific single page in Anqi CMS.

2025-11-06