How to prevent external links in AnQi CMS navigation from being tracked by search engines?

Calendar 👁️ 60

As an experienced security CMS website operator, I am well aware of the key role of website navigation in user experience and search engine optimization.Manage external links well in the navigation, ensuring they are processed according to our wishes by search engines is an indispensable aspect of website operation.

I will elaborate in detail on how to prevent external links in navigation links from being tracked by search engines in AnQi CMS.

The significance of external links and search engine tracking.

In website operation, we often need to add links to other websites in the navigation, such as partners, related resources, or social media pages.These external links are crucial for enhancing user experience and providing additional value.However, from the perspective of search engine optimization, too many external links or external links pointing to low-quality websites may dilute the "link equity" (Link Juice) of our website and even affect its reputation.To better control the impact of these external links on search engines, we would usually want to prevent search engines from tracking certain specific external links.

The search engine tracks a link mainly through the two processes of 'crawling' and 'transmitting link weight'. When we do not want the search engine to follow a link or pass link weight to the target website, we can userel="nofollow"The attribute tells the search engine crawler not to consider the link as an endorsement by the website of the target page, and not to pass PageRank to the target page.

Default behavior of AnQi CMS navigation link

The Anqi CMS is SEO-friendly in design, providing features such as static URLs, 301 redirects, and advanced SEO tools to help improve the website's search engine performance.In terms of content publishing, Anqi CMS's "Content Settings" includes a feature named "Whether to automatically filter external links".When this feature is enabled, external links inserted into the content of articles or pages will be automatically addedrel="nofollow"The attribute effectively manages the link weight loss in the content.

However, for website navigation (configured links through "website navigation settings"), the situation is somewhat different. The Anqi CMS navigation list label (navListIn the template output, there is no field provided directly to controlrel="nofollow"The option of the attribute. This means that by default, external links added to the navigation may be tracked by search engines and pass link weight.

For this reason, we need to take some additional methods to ensure that the external links in the navigation can also be controlled according to our needs.

Strategy one: Add manually through the template.rel="nofollow"property

This is the most direct and effective method, by modifying the website template files, manually adding navigation link HTML code in the generated navigation links.rel="nofollow"Property.

  1. Confirm navigation template file: The template files of AnQi CMS are usually located/templatein the directory, and organized according to certain conventions (refer todesign-convention.mdanddesign-director.md)。The navigation section is usually in the public code snippet, such aspartial/header.htmlor directly inindex.htmlintroduce. You need to find the one using{% navList navs %}label to generate the template file for navigation.

  2. Modify the template code:Find the rendered navigation link of<a>tag.tag-/anqiapi-other/165.htmlIn the example code, the structure of the navigation link is roughly as follows:

    {% navList navs %}
    <ul>
        {%- for item in navs %}
            <li>
                <a href="{{ item.Link }}">{{item.Title}}</a>
                {# 可能还有二级导航 #}
                {%- if item.NavList %}
                <dl>
                    {%- for inner in item.NavList %}
                        <dd>
                            <a href="{{ inner.Link }}">{{inner.Title}}</a>
                        </dd>
                    {% endfor %}
                </dl>
                {% endif %}
            </li>
        {% endfor %}
    </ul>
    {% endnavList %}
    

    Add to all external linksrel="nofollow"First, we need to determine,item.LinkIs it an external link. We can check if the link starts withhttp://orhttps://Start, and it does not belong to the current website domain to judge. At the same time, for security and user experience, it is recommended to add external links.target="_blank" rel="noopener noreferrer"Attribute, ensure that it opens in a new tab and prevents potential security vulnerabilities.

    You can modify the template code in the following way:

    {% navList navs %}
    <ul>
        {%- for item in navs %}
            <li>
                {# 假设 system.BaseUrl 是当前网站的基础URL #}
                {% set isExternal = (item.Link | startsWith('http://') or item.Link | startsWith('https://')) and not item.Link | contains(system.BaseUrl) %}
                <a href="{{ item.Link }}"
                   {% if isExternal %}target="_blank" rel="nofollow noopener noreferrer"{% endif %}>
                   {{item.Title}}
                </a>
                {%- if item.NavList %}
                <dl>
                    {%- for inner in item.NavList %}
                        {% set isExternalInner = (inner.Link | startsWith('http://') or inner.Link | startsWith('https://')) and not inner.Link | contains(system.BaseUrl) %}
                        <dd>
                            <a href="{{ inner.Link }}"
                               {% if isExternalInner %}target="_blank" rel="nofollow noopener noreferrer"{% endif %}>
                               {{inner.Title}}
                            </a>
                        </dd>
                    {% endfor %}
                </dl>
                {% endif %}
            </li>
        {% endfor %}
    </ul>
    {% endnavList %}
    

    NoteHere is thestartsWithandcontainsIt is a kind of template filter assumption, you need to adjust according to the actual filter supported by the safe CMS template engine.If not supported, it may require more complex logic or backend support.A more general way to judge is, if the link containshttp://orhttps://If it does not contain the domain name of your website, it is considered an external link.

  3. Utilize the "navigation description" field for selective control (recommended practice) If you only want to add some external links in the navigationrel="nofollow"Instead of all, it can be cleverly utilized by taking advantage of the 'Navigation Description' field in the 'Website Navigation Settings' of AnQi CMS.

    • Background operation:In the "Background Settings" -> "Website Navigation Settings" section, edit the links you want to addnofollowNavigation links. In the "Navigation Description" field, enter a specific keyword, such asnofollow.
    • Template modification:Modify in the template file,<a>Add a conditional check to the tag code,item.Descriptionwhether it contains the keywords you set.
    {% navList navs %}
    <ul>
        {%- for item in navs %}
            {% set isNofollow = item.Description | contains('nofollow') %} {# 检查描述是否包含 'nofollow' #}
            {% set isExternal = (item.Link | startsWith('http://') or item.Link | startsWith('https://')) and not item.Link | contains(system.BaseUrl) %}
            <li>
                <a href="{{ item.Link }}"
                   {% if isExternal %}target="_blank" rel="noopener noreferrer"{% endif %}
                   {% if isNofollow %}rel="nofollow"{% endif %}> {# 如果描述中包含 nofollow,则添加 #}
                   {{item.Title}}
                </a>
                {# 处理二级导航,逻辑类似 #}
            </li>
        {% endfor %}
    </ul>
    {% endnavList %}
    

    This approach is more flexible, allowing you to decide whether to add it based on the specific link's needsnofollow.

Strategy two: Use Robots.txt (Limited application scenarios)

AnQi CMS provides advanced SEO tools, including support for Robots.txt configuration (refer to thehelp-plugin-rewrite.mdThe Robots.txt file is a text file located in the root directory of a website, used to instruct search engine crawlers which pages can be indexed and which pages cannot be indexed.

However, it should be clearly stated that Robots.txt is mainly used to control search engine crawlers on yourInternal websitePage or directory access. It cannot directly control the tracking behavior of external links.If you place an external link in the navigation, Robots.txt cannot prevent search engines from following this link.

Therefore,Robots.txt is not an effective method to prevent navigation from tracking external links.Its purpose is to instruct search engines not to crawl certain sensitive or unimportant internal content on your website (such as admin paths, search result pages, etc.).

Strategy three: Consider future feature enhancements

As an operations personnel, I am well aware of the importance of convenience for daily management. Although it is currently possible to modify templates and utilize existing fields to achieve thisnofollow

Related articles

How do navigation links adapt to sites in different languages when AnQi CMS supports multi-language?

As a website operator who is deeply familiar with the operation of AnQiCMS, I know that a flexible and efficient multilingual support system is crucial for expanding the international market and improving user experience.AnQiCMS provides powerful functions in this field, especially in how navigation links adapt to sites of different languages. It ensures smooth and user expectations of global content display through intelligent mechanisms and flexible template tags.

2025-11-06

What will AnQi CMS do to sort navigation links if the 'display order' numbers are the same?

As a long-term website operator dealing with Anqi CMS, I am well aware of the importance of the navigation system for website user experience and content presentation.AnQi CMS provides us with flexible navigation management functions, among which the 'Display Order' field is the key to controlling the arrangement of navigation items.For website visitors, a clear and logical navigation structure is the foundation for quickly finding the information they need.The initial design of "Display Order" in AnQi CMS is to allow operators to precisely control the arrangement of navigation links.Its basic logic is very intuitive

2025-11-06

Can I set a navigation link in AnQi CMS that displays both Chinese and English subtitles?

As website operators who deeply understand the operation of AnQiCMS, we are well aware that in today's world where content globalization and user experience are increasingly important, how to flexibly display multilingual information is a key issue many operators face.In response to your inquiry about whether the AnQi CMS navigation link can display both Chinese and English subtitles, I can clearly tell you that AnQi CMS provides comprehensive support for this feature.

2025-11-06

How to implement dynamic styles for navigation links in Anqi CMS template, such as highlighting the current page?

In website operation, the navigation bar is not only the entrance for users to explore the content of the website, but also a key factor in enhancing user experience and the professionalism of the website.A smart highlight navigation system that can intuitively tell the user 'where are you', thus greatly improving the ease of use of the website.As an experienced AnQi CMS operator, I am well aware of the strength of its template system. Next, I will detail how to implement dynamic highlighting of navigation links in the AnQi CMS template.### Overview of AnQi CMS navigation mechanism The template engine of AnQi CMS uses syntax similar to Django

2025-11-06

What are the similarities and differences between the 'Friend Links' feature and the 'Navigation Settings' in AnQi CMS?

As a senior CMS website operation personnel, I know that each function in the content management system carries specific operation strategies and user experience objectives.In AnQi CMS, although the "Friend Links" and "Navigation Settings" both involve the management and display of website links, there are significant differences in design concepts, functional focus, application scenarios, and impact on website operations.Understanding these similarities and differences is crucial for us to efficiently utilize Anqi CMS to build and optimize websites.### Friend Links: The Bridge Between External Connections and SEO Strategies Friend Links

2025-11-06

In Anq CMS, besides the top navigation, what types of custom navigation can be created?

As an experienced Anqi CMS website operator, I am well aware that a flexible navigation system is crucial for the user experience and content management of the website.The Anqi CMS provides powerful custom capabilities in navigation functions, surpassing traditional top navigation, aiming to help operators build a website structure that better meets business needs and user habits.The navigation design concept of AnQi CMS is not limited to a single main navigation area, it allows operators to create diversified custom navigation according to different functional areas and content types of the website.

2025-11-06

How to set up the Anq CMS navigation to improve the depth of access to website content?

As an experienced security CMS website operation personnel, I know that the navigation system is crucial for improving the depth of website content access.A well-designed navigation not only guides users to find the information they need quickly but also stimulates their desire to explore, allowing them to stay longer on the website and visit more pages.AnQi CMS provides flexible and powerful navigation settings that can help us effectively achieve this goal.### Navigation, the guide of a website's structure and depth of content Website navigation is the first door of interaction between users and content

2025-11-06

How to accurately call the navigation links under the new navigation category after creating it in the template?

AnQiCMS as an efficient content management system, one of its core advantages lies in its powerful content organization and template customization capabilities.As a website personnel proficient in AnQiCMS operation, I am well aware of the importance of a flexible navigation system for user experience and website structure optimization.When you create a new navigation category in the background and want to present it accurately on the website front-end template, AnQiCMS provides intuitive and powerful template tags to meet this need.

2025-11-06