How to add the `target="_blank"` attribute to the pagination link of AnQiCMS?

Calendar 👁️ 64

Certainly, as an experienced website operations expert, I am happy to give you a detailed explanation of how to add pagination links in AnQiCMStarget="_blank"Properties. In such a flexible content management system as AnQiCMS, such custom requirements are usually implemented by modifying the template, and that is exactly where its strength lies.


Explore the new world of AnQiCMS pagination links: how to addtarget="_blank"property

During the process of building a website with AnQiCMS, we often encounter various personalized needs.By default, the navigation links within the website, including pagination links, are opened in the current browser window.This is usually**practice for improving users' browsing experience within the site.However, in certain specific operational scenarios, you may want pagination links to open in a new tab, for example, so that users can browse pagination content while still retaining the current page as a reference, or to coordinate with some specific marketing strategies.

AnQiCMS is known for its high-performance architecture based on the Go language and its flexible template system, making it easy to customize what seems complex.It adopts a syntax similar to the Django template engine, allowing us to delve into the template code level, precisely controlling every output detail of the page.

Understand the template mechanism of AnQiCMS

In AnQiCMS, everything you see in the frontend display is inseparable from its powerful template system. All template files are stored with.htmlsuffix, neatly organized./templateUnder the directory. When we need to modify the display logic or HTML structure of the website, we usually need to find the corresponding template file to edit.

For the pagination feature, AnQiCMS provides a built-in tag namedpaginationused to generate pagination navigation. This tag itself cannot directly control the links'targetThe property is responsible for outputting an HTML structure that includes pagination logic. Therefore, our task is to delve intopaginationFind those responsible for generating links in the internal HTML structure rendered by the tag<a>At the location of the tag, then add for ittarget="_blank"Property.

Locate the pagination template code

The pagination code of AnQiCMS usually does not exist independently in a separate file, but is included as part of the page list (such as article list, product list, tag list, etc.) in the corresponding list template file.

To find the pagination code you need to modify, you can locate it according to the type of the page:

  • Article list page: Usually locatedarchive/list.htmlorcategory/list.html(If the category displays document lists).
  • Product list pageSimilarly, it may beproduct/list.htmlin the corresponding category list template.
  • Tag document list page: Locatedtag/list.html.
  • Search results page: Locatedsearch/index.html.

Open these template files and you will find a block of the form{% pagination pages with show="5" %}. This block contains the specific logic for generating pagination links in AnQiCMS.

Manually modify the pagination link attribute

Now, let's take a typical pagination code snippet as an example and demonstrate how to addtarget="_blank"the attribute. The following istag-pagination.mdthe pagination tag example code given in:

<div class="pagination">
    {% pagination pages with show="5" %}
    <ul>
        <li>总数:{{pages.TotalItems}}条,总共:{{pages.TotalPages}}页,当前第{{pages.CurrentPage}}页</li>
        <li class="page-item {% if pages.FirstPage.IsCurrent %}active{% endif %}"><a href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a></li>
        {% if pages.PrevPage %}
            <li class="page-item"><a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a></li>
        {% endif %}
        {% for item in pages.Pages %}
            <li class="page-item {% if item.IsCurrent %}active{% endif %}"><a href="{{item.Link}}">{{item.Name}}</a></li>
        {% endfor %}
        {% if pages.NextPage %}
            <li class="page-item"><a href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a></li>
        {% endif %}
        <li class="page-item {% if pages.LastPage.IsCurrent %}active{% endif %}"><a href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a></li>
    </ul>
    {% endpagination %}
</div>

You can see that in this{% pagination %}tags inside, we have several<a>Tags correspond to "Home<a>Manually add tagstarget="_blank".

The modified code will be like this:

<div class="pagination">
    {% pagination pages with show="5" %}
    <ul>
        <li>总数:{{pages.TotalItems}}条,总共:{{pages.TotalPages}}页,当前第{{pages.CurrentPage}}页</li>
        <li class="page-item {% if pages.FirstPage.IsCurrent %}active{% endif %}">
            <a href="{{pages.FirstPage.Link}}" target="_blank" rel="noopener noreferrer">{{pages.FirstPage.Name}}</a>
        </li>
        {% if pages.PrevPage %}
            <li class="page-item">
                <a href="{{pages.PrevPage.Link}}" target="_blank" rel="noopener noreferrer">{{pages.PrevPage.Name}}</a>
            </li>
        {% endif %}
        {% for item in pages.Pages %}
            <li class="page-item {% if item.IsCurrent %}active{% endif %}">
                <a href="{{item.Link}}" target="_blank" rel="noopener noreferrer">{{item.Name}}</a>
            </li>
        {% endfor %}
        {% if pages.NextPage %}
            <li class="page-item">
                <a href="{{pages.NextPage.Link}}" target="_blank" rel="noopener noreferrer">{{pages.NextPage.Name}}</a>
            </li>
        {% endif %}
        <li class="page-item {% if pages.LastPage.IsCurrent %}active{% endif %}">
            <a href="{{pages.LastPage.Link}}" target="_blank" rel="noopener noreferrer">{{pages.LastPage.Name}}</a>
        </li>
    </ul>
    {% endpagination %}
</div>

Key modification point:

  1. target="_blank"This attribute indicates that the browser should open the link in a new tab or window.
  2. rel="noopener noreferrer"This is a very important security and performance enhancement attribute, especially when usedtarget="_blank".
    • noopener: Prevent new pages from accessingwindow.openerthe properties of the original pagewindowAn object, to prevent malicious new pages from using the original page's permissions to execute cross-site scripting attacks.
    • noreferrer: BesidesnoopenerIn addition to its functionality, it also prevents the new page from receiving the HTTP Referer header information from the original page, which is very helpful for protecting user privacy and preventing information leakage.

Save and take effect

After modifying the template file, please make sure to save the changes. Due to the cache mechanism that AnQiCMS may use to speed up page loading, in order for your changes to take effect immediately, you need to perform the following operations:

  1. Clear system cacheLog in to the AnQiCMS backend, find the "Update Cache" feature (usually at the bottom of the sidebar or in system settings), and click to clear all caches.
  2. Clear browser cachePress on the front-end page:Ctrl + F5(Windows/Linux) orCmd + Shift + R(macOS) Perform a hard refresh to ensure the browser loads the latest CSS and JS files, as well as the updated HTML structure.

Potential impact and suggestions

As a website operations expert, I must remind you to add properties for internal pagination links.target="_blank"In most cases, this is not a **good practice for user experience.

  • User Experience (UX)The user usually expects internal links to open in the current tab to maintain the continuity of the browsing path.Continuously opening new tabs can lead to too many tabs in the user's browser, causing confusion and disorientation, and may even result in them closing your website.
  • Search Engine Optimization (SEO): Althoughtarget="_blank"It does not have a direct negative impact on SEO, but if overused, especially on internal links, it may indirectly affect user behavior metrics (such as bounce rate), which may have an adverse effect on SEO.Search engines tend to favor websites that provide a smooth, intuitive user experience.

Therefore, please be sure to carefully evaluate the impact of such changes on your website's target user group and overall operational strategy.If you indeed have special requirements, such as at a critical link in some data analysis or marketing funnel, where you want users to process tasks "simultaneously", then customization is feasible under the premise of fully understanding the risks.


Frequently Asked Questions (FAQ)

  1. Why does AnQiCMS pagination links not open in a new tab by default?AnQiCMS and other mainstream CMSs are the same, the default design is to open internal links in the current tab, which is based on the **user experience practice of website internal navigation.Users are expected to navigate within a website in a coherent manner, rather than accumulating new browser tabs continuously.

  2. Add pagination linkstarget="_blank"Will it have a negative impact on my website's SEO?Add directlytarget="_blank"The attribute itself will not directly lead to SEO punishment.However, if this approach leads to a poor user experience (for example, the user feels confused and closes the website prematurely), it may indirectly affect user behavior metrics (such as dwell time, bounce rate), which are important references for search engines to evaluate website quality.rel="noopener noreferrer"Property to avoid

Related articles

Is the pagination tag considering the `BaseUrl` and `MobileUrl` settings of the website when generating URLs?

As an expert in website operation for many years, I know the importance of URL structure for website SEO and user experience.In a system like AnQiCMS, which emphasizes efficiency and optimization, how does its internal mechanism handle these fundamental and critical configurations, which is a concern for many operators.Today, let's delve into whether the pagination tag considers the `BaseUrl` and `MobileUrl` settings of the website when generating URLs?This topic.

2025-11-07

How to implement a feature similar to 'jump to page X' input box in AnQiCMS template?

As an experienced website operations expert, I know how common it is for users to need to quickly locate a specific page while browsing a large list of content.Especially in a high-efficiency and flexible content management system like AnQiCMS, it provides users with a convenient navigation experience, which can significantly improve the usability and user satisfaction of the website.Today, let's delve into how to cleverly implement a function similar to 'jump to page X' in the AnQiCMS template.

2025-11-07

If `archiveList` returns data less than `limit`, will the `pagination` tag still be displayed?

As an experienced website operation expert, I have a deep understanding of AnQiCMS (AnQiCMS) and often encounter users who have questions about the behavior of certain tags during template development.TodayThis issue concerns the elegance of page layout, the smoothness of user experience, and potential SEO optimization

2025-11-07

Does the pagination label automatically handle the `_page` parameter in the URL?

In the world of website operation, content pagination is an indispensable part.It not only optimizes page loading speed and improves user experience, but is also an important part of search engine optimization (SEO) strategy.When discussing an enterprise-level content management system like AnQiCMS, a common and critical issue is how does it handle pagination tags in URL pagination parameters, such as the `_page` parameter we often see?Today, let's delve deep into the performance of AnQi CMS in this aspect.### Enterprise CMS Pagination Tag

2025-11-07

`pages.TotalItems`Will it dynamically update to the total number of items after filtering?

## Unveiling the `pages.TotalItems` in AnQi CMS: Does it make the final decision after filtering?As a senior website operations expert, I know that the pursuit of data accuracy and user experience in daily content management is endless.Especially when it comes to displaying and filtering a large amount of content, every detail may affect the user's perception of the website.

2025-11-07

Does AnQiCMS support setting cache for pagination tags to improve access speed?

In today's fast-paced online world, website loading speed is not only a measure of user experience, but also a key factor in search engine optimization (SEO) and business success.As an expert who has been deeply involved in website operations for many years, I know that every millisecond of delay can affect user retention and conversion.Therefore, when discussing whether the pagination tag of AnQiCMS (AnQiCMS) supports setting cache to improve access speed, this is undoubtedly a practical problem that hits the core.AnQi CMS, this is an enterprise-level content management system developed based on Go language

2025-11-07

What are the common check steps or tools when debugging pagination display issues?

As an experienced website operations expert, I am well aware of the importance of pagination for user experience and content management.When a user is browsing a large amount of content, a smooth and effective pagination system can greatly enhance their experience.However, in actual operation, incorrect or失效 pagination is often a headache problem.Don't worry, AnQiCMS (AnQiCMS) with its high-performance architecture in Go language and flexible template system, makes it traceable to investigate these issues.

2025-11-07

How to add different styles to pagination links based on the parity of the page number in a `for` loop?

As an experienced website operation expert, I know that the charm of an attractive and user-friendly website often lies in the details.In AnQiCMS (AnQiCMS) such a content management system based on Go language, powerful and flexible in templates, even simple pagination navigation, we can also make it come alive with clever design, providing users with a more intuitive and pleasant browsing experience.Today, let's discuss a practical and interesting skill: how to use the `for` loop in AnQiCMS

2025-11-07