How to exclude documents of a specific category in `archiveList` to display accurate content?

Calendar 👁️ 57

As an experienced website operation expert, I know the importance of the accuracy of content display for user experience and website operation efficiency.In a content management system, we often encounter the need: when generating an article list, we need to exclude certain specific category documents to ensure the relevance and focus of the content.AnQiCMS (AnQiCMS) is an efficient and flexible content management tool that provides us with a very convenient solution.archiveListIn the tag, cleverly use parameters to exclude specific categories of documents to achieve precise content display.

When building website content, we may have various types of articles, such as news updates, product introductions, technical tutorials, company announcements, as well as test drafts or expired event information.If all the content is listed on a page without distinction, it may dilute the core information, distract the user's attention, and even affect the professional image of the website.For example, the homepage of a technology blog usually displays the latest technical articles, but we may not want to mix in documents such as 'internal team building activities' or 'website update logs' that are only for specific audiences.In this case, it is particularly important to accurately exclude certain categories.

AnQi CMS provides us with a flexible content call mechanism through its powerful template tag system. Among them,archiveListTags are the core tools used to retrieve various document lists, whether it is a regular article list, a paged list, or related documents associated with keywords, it can handle it. To achieve the purpose of excluding specific categories,archiveListA key parameter in the label -excludeCategoryIdIt is our powerful assistant.

excludeCategoryIdThe role of the parameter is very direct: it tellsarchiveListLabel, when querying documents, please ignore all documents under the specified category ID. This means that even if these documents meet other filtering conditions (such as model ID, recommendation attributes, etc.), as long as their category ID is listed underexcludeCategoryIdIt will not appear in the final list.

UseexcludeCategoryIdThe parameter is very simple.First, we need to know the ID of the categories to be excluded.This can be viewed on the "Content Management" -> "Document Category" page in the Anqi CMS backend.Each category has a unique numeric ID.Assuming we want to exclude the documents of the 'Company Internal Announcement' category with ID 5 and the 'Expired Activities' category with ID 12.

Next, we just need to find the template file that needs to be modified (such as the homepage of the website's)index.html, or some special list page'scategory/list.html) to find it.archiveListLabel, and add or modifyexcludeCategoryIdThis parameter can accept a single category ID, or multiple category IDs separated by commas.

Let us demonstrate with an actual code snippet:

{# 假设我们希望在网站首页展示最新的文章,但排除ID为5和12的分类文档 #}
<div>
    <h3>最新动态</h3>
    <ul>
        {% archiveList archives with type="list" limit="10" excludeCategoryId="5,12" %}
            {% for item in archives %}
                <li>
                    <a href="{{item.Link}}">{{item.Title}}</a>
                    <span>发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                    <span>浏览量:{{item.Views}}</span>
                </li>
            {% empty %}
                <li>抱歉,没有找到符合条件的文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

In this example,type="list"Indicates retrieving a fixed number of lists,limit="10"Limited to displaying 10 articles, andexcludeCategoryId="5,12"It ensured that documents with category IDs 5 and 12 will not appear in this "latest news" list.This is the content that has been carefully selected and is more relevant, presented to the user.

Reasonably utilizing in actual operation,excludeCategoryIdParameters, help us better manage the lifecycle of content. For example, for some temporary promotional activities or internal materials, we can set up a separate category for them, and display them on the main list of the front end throughexcludeCategoryIdParameters are excluded.When this content is no longer needed to be exposed, there is no need to delete it either. Just make sure it is still excluded, which greatly reduces maintenance costs.At the same time, this exclusion mechanism has a relatively controllable impact on the website's SEO.The excluded document can still be found through other channels if it has an independent detail page and is indexed by search engines, and the refined list page can help improve the relevance of core keywords.

In short, the Anqi CMS'sarchiveListwith the tag andexcludeCategoryIdThe combination of parameters provides powerful content refining capabilities for website operators.By simple parameter configuration, we can achieve precise control in complex content structures, providing users with a better and more focused browsing experience, thereby enhancing the overall value of the website.


Frequently Asked Questions (FAQ)

Q1:excludeCategoryIdandcategoryIdCan parameters be used at the same time? What is their priority?

A1:Yes,excludeCategoryIdandcategoryIdParameters can be used at the same time. When you specify both of these parameters in aarchiveListtag, AnQiCMS will first check according tocategoryIdFilter documents under a specific category (i.e., "which categories include"), and then exclude them from this result setexcludeCategoryIdDocuments specified by the parameter. This meanscategoryIddefined the initial inclusive range, whileexcludeCategoryIdThen perform the "subtraction" operation within this range. This combination is very flexible and can help you build very precise content filtering logic.

Q2: If I want to exclude a lot of categories, is there a more concise method than listing all category IDs one by one?excludeCategoryIdCurrently?

A2:CurrentlyexcludeCategoryIdYou need to explicitly list the category IDs to be excluded (separated by commas). If the number of categories to be excluded is huge and difficult to manage, you can consider optimizing your content structure:

  1. Exclude parent category: Place all subcategories to be excluded under a specific parent category, and then you can try to exclude just that parent category. InarchiveListthe default behavior of tags, ifchild=true(Default value), excluding the parent category will also exclude all its child categories.
  2. Recommended attribute (Flag): For documents that you do not want to display, you can consider setting a specific "recommended attribute" (for example, a custom "hidden" attribute) during backend editing, thenarchiveListpass throughexcludeFlagParameters to exclude documents containing the property.
  3. Template logic judgment: If the above method does not apply, you can also inarchiveListUse within the loop,{% if item.CategoryId != 排除ID %}This logical judgment to skip documents that do not want to be displayed, but it will increase the complexity of the template and may affect performance, it is better to exclude efficiently in the tag parameters directly.

Q3: After excluding documents of a specific category, will these documents still be indexed by the search engine?

A3: excludeCategoryIdThe parameter only controls the display of the list on the front-end page, it does not directly interfere with the crawling and indexing behavior of search engines. If the excluded document itself has an independent detail page, and these detail pages do not setnoindex(Forbidden index) Meta tag, not indexedrobots.txtThe file is prohibited from being indexed by search engines, but search engines can still find and index these documents through other paths (such as Sitemap of the website, internal links on other pages, or even links from external websites). If you really do not want certain categories or documents to be indexed by search engines, it is recommended to set this at the level of the detail page or category page of these documents.noindexMetadata, androbots.txtconfigure accordingly.

Related articles

How to filter and display documents based on multiple category IDs for the `archiveList` tag?

As an experienced website operations expert, I fully understand that the flexibility of a content management system is crucial for efficient operations.AnQiCMS (AnQiCMS) provides us with great convenience with its powerful template tag system.Today, let's delve deeply into a very practical feature: how to use the `archiveList` tag to filter and display documents based on multiple category IDs, thereby creating more targeted and attractive content modules.

2025-11-06

How to use the `archiveList` tag of AnQiCMS to get the document list under a specified content model?

AnQiCMS Content Management: The secret to accurately obtaining the document list with the `archiveList` tag As an experienced website operations expert, I know that the core value of a content management system (CMS) lies in its ability to organize and display content.In the AnQiCMS, this efficient and flexible Go language content management system, the `archiveList` tag is undoubtedly a powerful weapon in the content display process.It is not just a simple content call tag, but also a key bridge connecting your website content model with the front-end display logic.

2025-11-06

`archiveFilters` label can be combined with AnQiCMS's multilingual support to provide multilingual filtering conditions?

As an experienced website operations expert, I have accumulated rich experience in the content management and operations practice of AnQiCMS.Today, we will delve into a commonly discussed issue by users: Can AnQiCMS's `archiveFilters` tag be combined with multilingual support to provide multilingual filtering conditions?To answer this question, we need to understand the multilingual mechanism of AnQiCMS and the working principle of the `archiveFilters` tag.AnQiCMS as an enterprise-level content management system

2025-11-06

How will the `archiveFilters` tag display and handle if a document belongs to multiple filter parameter values?

## AnQi CMS `archiveFilters` tag: How will it elegantly present when a document meets multiple filter conditions?As an experienced website operations expert, I am well aware that the discoverability of content is crucial for user experience and SEO.AnQiCMS provides many powerful and flexible features in content management, among which the `archiveFilters` tag is undoubtedly a powerful tool for building advanced filtering interfaces and improving content navigation efficiency.

2025-11-06

How to use the `archiveList` tag to get documents with specific recommended attributes (such as "Top Stories" or "Slideshow")?

As an experienced website operations expert, I am well aware of the core value of a content management system (CMS) in terms of its flexibility and content scheduling capabilities.AnQiCMS (AnQiCMS) boasts its efficient architecture based on the Go language and rich features, providing strong support for content operations.Today, let's delve into a very practical scenario in content operation: how to accurately obtain and display documents with specific recommendation attributes using the `archiveList` tag, such as the website's 'headlines' news or important content for the 'slideshow' carousel.

2025-11-06

How to implement sorting of the document list by views or publication time using the `archiveList` tag?

As an experienced website operations expert, I know that the core value of a content management system (CMS) lies in its flexibility and the efficiency of content presentation.AnQiCMS (AnQiCMS) excels in this aspect with its efficient architecture in the Go language and a rich set of features.Today, let's delve deeply into a function that is extremely commonly used in content operation: how to use the `archiveList` tag to sort the document list by views or publication time.Content sorting seems simple, but it actually contains profound operational strategies.

2025-11-06

How to set the display quantity and offset for the `archiveList` tag in AnQiCMS to achieve pagination?

As an experienced website operations expert, I know that an efficient and flexible list display method is crucial for user experience and website performance.AnQiCMS (AnQiCMS) provides us with great convenience with its powerful template tag system.Today, let's delve into how to cleverly set the display quantity and offset using the AnQiCMS `archiveList` tag to achieve a smooth pagination effect.

2025-11-06

How to use the `archiveList` tag to perform keyword search (using `q` parameter) to filter documents on the frontend page?

## Unlock AnQiCMS: Use the `archiveList` tag to implement keyword search and content filtering on the front-end page As an experienced website operations expert, I am well aware of the importance of an efficient and flexible content management system for enterprises.AnQiCMS, this system developed based on the Go language, with its excellent performance and rich features, is becoming the preferred choice for an increasing number of small and medium-sized enterprises and content operation teams.In today's era of information explosion, whether users can quickly find the content they need is directly related to the user experience and conversion rate of the website.

2025-11-06