How can the breadcrumb navigation of the current position be displayed on the page?

Calendar 👁️ 72

In website navigation, Breadcrumb navigation is a very practical auxiliary tool.It clearly shows the user's current position on the website, provides a convenient return path, thereby significantly improving the user experience, and also has a positive effect on search engine optimization (SEO), helping search engines understand the structural hierarchy of the website.

AnQiCMS has fully considered this point, providing a simple and powerful way to display breadcrumb navigation on the page.With built-in template tags, even without complex programming knowledge, this feature can be easily implemented.

Breadcrumbs navigation label in AnQiCMS

AnQiCMS provides a dedicated template tagbreadcrumbTo handle the generation and display of breadcrumb navigation. This tag will automatically build a complete navigation path based on the URL structure of the current page.

UsebreadcrumbThe basic syntax of the tag is as follows:

{% breadcrumb crumbs with index="首页" title=true %}
    {# 您的面包屑导航渲染代码 #}
{% endbreadcrumb %}

here,crumbsIs the variable name you define for the breadcrumb list, you can name it according to your own preference.indexandtitleAre two commonly used parameters for customizing the breadcrumb navigation:

  • indexThis parameter is used to set the display text of the "Home" in the breadcrumb navigation.By default, it will display as "Home Page". If you want to change it to "Website Homepage" or "Home", just setindex="网站主页"Pass in as is.
  • titleThis parameter controls the display method of the current page title in the breadcrumb navigation.
    • When set totrueBy default, the breadcrumbs will display the full title of the current page.
    • When set tofalseIf it is, the title of the current page will not be displayed.
    • You can also pass a custom string, such astitle="文章详情", and the part of the current page will be displayed as the text you specified.
  • siteIdThis is an advanced parameter for multi-site users, usually you do not need to set it.If you manage multiple sites in the background and need to call data for a specific site, you can specify the site ID through this parameter.

WhenbreadcrumbAfter the tag is executed, it will store the generated breadcrumb path to the one you definecrumbsthe variable.crumbsis an array containing multiple objects, each representing a navigation path segment, they have two key fields:

  • Name: indicates the display name of the segment.
  • LinkIndicates the URL address of the corresponding link.

How to display breadcrumb navigation on the page

It is usually recommended to place the breadcrumb navigation in the public template file of the website (for examplebase.htmlOr create a separate template snippet (such aspartial/breadcrumb.htmlThen proceedincludeTag it to the page where it needs to be displayed. The benefit of this is that once the breadcrumb display logic or style is modified, all pages that refer to it will be updated synchronously, greatly improving maintenance efficiency.

Here is an example of code that displays breadcrumb navigation in a template:

<nav class="breadcrumb-nav">
    {% breadcrumb breadcrumbs with index="首页" title=true %}
    <ol class="breadcrumb-list">
        {% for item in breadcrumbs %}
            <li class="breadcrumb-item">
                <a href="{{ item.Link }}">{{ item.Name }}</a>
            </li>
        {% endfor %}
    </ol>
    {% endbreadcrumb %}
</nav>

In this code block:

  1. We usenavThe tag wraps the entire breadcrumb navigation and assignsbreadcrumb-navClass name, convenient for subsequent style control.
  2. {% breadcrumb breadcrumbs ... %}Defined the breadcrumb data source and assigned it tobreadcrumbsVariable.
  3. {% for item in breadcrumbs %}Loop throughbreadcrumbsEach navigation item in the array.
  4. Inside the loop,{{ item.Link }}Will output the current navigation item link,{{ item.Name }}Then output its display name. We place it in<li>Presented within the tag in list form.
  5. Finally, remember to use{% endbreadcrumb %}tag to end the breadcrumb tag block.

If you wish to make more personalized settings, you can adjust it like this.breadcrumbLabel's parameters:

  • Modify the home page text and disable the current page title:

    {% breadcrumb breadcrumbs with index="网站主页" title=false %}
    

    In this way, the first link of the breadcrumb will display as "Home Page" of the website, and the title of the current page itself will not appear at the end of the breadcrumb.

  • Customize the current page title display text:

    {% breadcrumb breadcrumbs with index="首页" title="当前页面信息" %}
    

    At this time, the last link of the breadcrumb will display as "Current Page Information", rather than the actual title of the page.

Summary

AnQiCMS'breadcrumbLabels make the website's breadcrumb navigation feature accessible.With just a few lines of simple template code, you can provide users with a clear navigation path and optimize the website's hierarchy structure.At the same time, with the help of CSS styles, you can easily integrate breadcrumb navigation into the overall design of the website, providing a beautiful and functional user experience.


Frequently Asked Questions (FAQ)

Q1: Does breadcrumb navigation automatically recognize the hierarchical structure of the website?A1: Yes, it is of AnQiCMS.breadcrumbThe label will intelligently parse and generate the corresponding hierarchical path based on the current page URL path and content (such as articles, categories, single pages, etc.) and the association with the system data.You do not need to manually specify each level.

Q2: How to modify the display style of breadcrumb navigation?A2: breadcrumbThe tag outputs a standard HTML list structure (usually<ol>or<ul>enclosed<li>element). Therefore, you can completely customize its style using CSS. Simply add an appropriate class name to the breadcrumb container or list item, as shown in the example.breadcrumb-nav,breadcrumb-list,breadcrumb-item),Then write the corresponding CSS rules.

Q3: Can I disable breadcrumbs navigation on specific pages or only show them on certain pages?A3: Of course you can. You can use conditional judgment in the template file of the page.breadcrumbRendering of tags. For example, do not place breadcrumbs in the page template where they are not needed.{% breadcrumb ... %}Code, or use{% if 当前页面不需要面包屑 %}{% else %}{% breadcrumb ... %}{% endif %}Such logic to selectively display.

Related articles

How to build a multi-level navigation menu in AnQiCMS to optimize the display of the website structure?

The website's navigation system, like a city map, guides visitors to explore every corner of your website. A clear, intuitive multi-level navigation not only greatly enhances the user experience but is also an indispensable part of Search Engine Optimization (SEO), helping search engines better understand the structure of the website and thereby improve content inclusion and ranking.In AnQiCMS, building a set of efficient and beautiful multi-level navigation menus is actually simpler than you imagine. It provides flexible backend configuration and powerful template tags, allowing you to easily implement it.Build Navigation Basics

2025-11-08

How to dynamically generate and display the page's SEO title, keywords, and description (TDK)?

Search engine optimization (SEO) is a key factor for the success of a website, and the page title (Title), keywords (Keywords), and description (Description), which we often call TDK, are also the core elements for search engines to understand and display your web content.They not only affect the willingness of users to click on search results, but also directly relate to the ranking performance of the website in search engines.AnQiCMS is a corporate-level content management system that has fully considered SEO friendliness from the outset

2025-11-08

How to correctly obtain and display contact information in the template?

In website operation, clearly and effectively displaying contact information is crucial for user experience and business conversion.AnQiCMS (AnQiCMS) provides us with flexible and powerful features, allowing us to easily retrieve and display these key information in templates. --- ### **Backend Configuration: Source of Contact Information** All website contact information is centralized in the backend for unified management in AnQi CMS.This means that whether you need to modify the contact phone number, email, or add new social media links, you do not need to touch any code, just perform simple operations in the background

2025-11-08

How to accurately call the system settings (such as website name, Logo) in the template for display?

As AnQi CMS users, we often need to ensure that the core information of the website, such as the website name, Logo, filing number, etc., is displayed accurately and correctly on all pages of the website.This concerns the unity of brand image, and it directly affects user experience and search engine optimization.AnQi CMS with its efficient architecture based on the Go language and template engine syntax similar to Django, makes the invocation of these basic information intuitive and flexible.Next, let's explore how to easily call and display these important system settings in the Anqi CMS template.Useful ###

2025-11-08

How to display category lists on the homepage or category pages?

In Anqi CMS, managing and displaying the category list is the core of website content organization.It is crucial to clearly display the classification structure for optimizing user navigation experience or improving search engine crawling efficiency.The Anqi CMS provides concise and powerful template tags, allowing you to easily display your content categories on the homepage, category pages, or any place you need.### Understanding Core: `categoryList` Tag In the AnQiCMS template system, the main tag used to retrieve the category list is `categoryList`

2025-11-08

How to retrieve and display detailed information for a specific category, such as the category logo and introduction?

In website operation, a clear and informative classification display is the key to attracting visitors, improving user experience, and optimizing search engine rankings.AnQiCMS provides a user-friendly and powerful template tag system that allows you to flexibly obtain and display detailed information of various categories on your website, such as category logo and introduction, thereby creating a more attractive content layout. ### Understand Category Information Management and Configuration Category information management is very convenient in the Anqi CMS backend.When you enter the 'Content Management' under 'Document Category' to add or edit

2025-11-08

How to list and display the titles and links of all single pages?

AnQi CMS provides a user-friendly and powerful content management system, where the single-page feature is an ideal choice for building independent pages such as "About Us", "Contact Information", or "Privacy Policy".When you need to display the titles and links of these single-page in a centralized position on the website, such as in the footer navigation, sidebar, or a dedicated page index, the template tags of AnQiCMS can help you easily achieve this.In the AnQiCMS backend, single-page content is created and maintained under "Page Resources" > "Page Management".You can easily add to the website like 'About Us'

2025-11-08

How to retrieve and display the complete content and images of a specific single page?

Use AnQiCMS to manage and display website content, especially when dealing with independent and rich single-page content such as "About Us" and "Contact Information", its flexibility and powerful functions are particularly prominent.We often need to present the text, images, and even image sets of these pages in their entirety on the website, and AnQiCMS provides a very intuitive way to achieve this. Let's explore together how to retrieve and display the complete content and images of a specific single page in AnQiCMS, making your website content more vivid and diverse.## Content Creation

2025-11-08