How to exclude certain pages from displaying breadcrumb navigation in AnQiCMS using conditional judgment?

Calendar 👁️ 66

As an experienced website operations expert, I am well aware of the importance of breadcrumb navigation in enhancing user experience and website SEO.It not only helps users clearly understand their current location, but also assists search engines in understanding the structure of the website.However, in certain specific scenarios, we may want some pages not to display breadcrumb navigation, such as the homepage, login page, registration page, or some special marketing landing pages, in order to maintain the simplicity of the page or highlight the core content.

AnQiCMS (AnQiCMS) provides us with a perfect tool to meet this requirement with its flexible and powerful template engine.AnQiCMS template system is based on syntax similar to Django, allowing content managers and developers to easily control the display and hide of page elements through conditional judgments.

Overview of AnQi CMS template mechanism

AnQiCMS template files are usually stored in/templateUnder the directory, commonly used reusable code snippets (such as headers, footers, sidebars, breadcrumbs, etc.) are usually organized inpartial/directory. In the main template file (such asbase.html) we will use{% include "partial/breadcrumb.html" %}This tag is used to introduce breadcrumb navigation. To hide the breadcrumbs conditionally, we just need to add judgment logic where the breadcrumb code is introduced.

AnQiCMS template language support{% if 条件 %}/{% elif 其他条件 %}/{% else %}and{% endif %}Such logical judgment tags, as well as{{ 变量 }}Used for output content. By combining these tags, we can accurately control the display behavior of breadcrumbs.

Core Strategy: Make good use of conditional judgment

To implement the conditional hiding of breadcrumb navigation in AnQiCMS, the core strategy is to use the properties of the current page (such as page ID, URL path, or even custom fields) as the basis for judgment, and then use{% if %}Code to determine whether to render breadcrumb navigation.

Here are several common methods for determining page type and properties, as well as how to apply them in templates.

Method one: Exclude specific pages through page ID

For a few fixed ID pages, we can directly judge by their ID. AnQiCMS'stdk(Universal TDK tag) can retrieve basic information about the current page, including the page ID.

Implementation steps:

  1. Locate the position of the breadcrumb navigation introduction:Generally speaking,template/你的模板名/base.htmlortemplate/你的模板名/partial/header.html.{% include "partial/breadcrumb.html" %}Or directly write the position of the breadcrumb code.
  2. Get the current page ID:Use{% tdk currentId with name="Id" %}Tag to get the current page ID.
  3. Write a conditional judgment:UseifCheck if the current ID is in the exclusion list.

Code example:

Assume you want to hide breadcrumbs on pages with ID 10 (such as the "About Us" page) and ID 15 (such as a specific article detail page).

{# 在面包屑导航的上方或外部文件中获取当前页面的ID #}
{%- tdk currentId with name="Id" %}

{# 编写条件判断,排除ID为10和15的页面 #}
{% if currentId != 10 and currentId != 15 %}
    {% breadcrumb crumbs %}
        <div class="breadcrumb-nav">
            <ul class="flex items-center space-x-2">
                {% for item in crumbs %}
                    <li class="flex items-center">
                        <a href="{{ item.Link }}" class="text-gray-600 hover:text-blue-500">{{ item.Name }}</a>
                        {% if not forloop.Last %}
                            <svg class="w-4 h-4 mx-1 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>
                        {% endif %}
                    </li>
                {% endfor %}
            </ul>
        </div>
    {% endbreadcrumb %}
{% endif %}

HeretdkLabels will

Related articles

What is the difference in the generation logic of AnQiCMS breadcrumb navigation on article detail pages and category list pages?

## AnQiCMS breadcrumb navigation: What is the difference between the generation logic of the article detail page and the category list page?In a content management system, breadcrumb navigation is one of the key elements for user experience and search engine optimization (SEO).It displays the user's position on the website in a clear path, not only helping users quickly understand the structure of the website but also effectively improving the usability of the website and the crawling efficiency of search engines.As an experienced website operations expert, I deeply understand the exquisite design of AnQiCMS in this detail.

2025-11-06

What can be placed between `{% breadcrumb %}` and `{% endbreadcrumb %}` of AnQiCMS breadcrumb navigation tag?

As an experienced website operations expert, I know that the navigation structure of a website plays a crucial role in user experience and search engine optimization (SEO).Clear breadcrumb navigation not only helps users understand their location on the website but also provides valuable website structure information for search engines.AnQiCMS as a powerful and flexible content management system provides us with the `{% breadcrumb %}` tag to easily build breadcrumb navigation. However

2025-11-06

How to add icons or additional text to breadcrumb navigation items in AnQiCMS template?

As an experienced website operations expert, I am well aware of the importance of breadcrumb navigation in website user experience (UX) and search engine optimization (SEO).It not only clearly tells the user where they are, helping them easily backtrack, but also provides clues about the structure of the website to search engines.However, most of the time, the default breadcrumb navigation seems too plain, lacking personality and visual guidance.

2025-11-06

What is the default display behavior and level depth of the AnQiCMS breadcrumb navigation?

As an experienced website operation expert, I am well aware of the importance of breadcrumb navigation in website user experience and search engine optimization.It not only indicates the current position for users, provides a convenient return path, but also provides important clues for the website structure of search engines.AnQiCMS takes full consideration of the intelligence, automation, and highly customizable design in the breadcrumb navigation, aiming to help operators easily build a clear website hierarchy.### The core logic and default behavior of AnQiCMS breadcrumb navigation In AnQiCMS

2025-11-06

How to use AnQiCMS breadcrumb navigation with other logical tags in Django template engine (such as `for`, `if`)?

## AnQi CMS: Make smart and efficient breadcrumb navigation using Django template tags As a senior website operations expert, I deeply understand the indispensable role of breadcrumb navigation (Breadcrumb Navigation) in website user experience (UX) and search engine optimization (SEO).It can clearly show the user's current position on the website, guide the user to conveniently backtrack the path, and also help search engines understand the hierarchical structure of the website, improve crawling efficiency and ranking.

2025-11-06

What is the specific performance and configuration method of AnQiCMS breadcrumb navigation in single-page (Page) type content?

As an experienced website operations expert, I know the importance of breadcrumb navigation in enhancing user experience and optimizing search engine rankings (SEO).It can clearly show the user's current position on the website, avoid getting lost, and also help search engines understand the hierarchy of the website.Today, let's delve into the specific performance and flexible configuration methods of breadcrumb navigation in AnQiCMS for single-page (Page) content type.

2025-11-06

How to accurately distinguish and display the path of different content models (such as articles, products) in the AnQiCMS breadcrumb navigation?

The website is operational, user experience and search engine optimization (SEO) are always the two core concerns.And a well-designed, clear hierarchy breadcrumb navigation (Breadcrumb Navigation) undoubtedly plays a key role in both aspects.It not only helps users clearly understand their position on the website, quickly return to the upper-level page, but also provides the search engine with clues about the website structure to improve the crawling efficiency.As an experienced website operation expert, I know the flexibility of AnQiCMS (AnQi CMS) in content management.

2025-11-06

When the breadcrumb navigation path of AnQiCMS is too long, what are some recommended optimization methods for display?

As an experienced website operation expert, I am well aware of the importance of breadcrumb navigation in enhancing user experience and optimizing search engine rankings.AnQiCMS (AnQiCMS) provides us with powerful content operation support with its flexible template engine and rich tag system.However, when the content hierarchy of a website is deep, the breadcrumb navigation path becomes long, and how to elegantly display it has become a topic worth discussing.The template creation of AnQi CMS follows the Django template engine syntax, which means we have great freedom to control the presentation of content

2025-11-06