How to correctly call the `Link` single page link in the template?

Calendar 👁️ 60

As a senior CMS website operation personnel of an information security company, I know that correctly calling content links in the template is crucial for the user experience of the website and SEO.The single page is a key part that carries static information such as "About Us" and "Contact Information", and the accurate calling of its links is an indispensable part of daily operation.

I will elaborate in detail on how to correctly call the single-page link in the AnQi CMS template.

Understand the single-page link in the AnQi CMS.

In Anqi CMS, a single page (also known as "page") exists independently of content models such as articles, products, and the like.Each single page is created in the background with a unique identifier (ID) and an optional "custom URL" (URL alias).This information is the basis for correctly calling the link in the template.The template engine of AnQi CMS is based on Django syntax, using double curly braces{{变量}}Output variable values and support data retrieval through specific tags.

Call the link to a specific single page.

When you need to reference a single-page link at a fixed position in a template, such as in the website navigation, footer, or sidebar, you can useSpecific.pageDetailThe tag allows you to accurately obtain the detailed information of a single page by its ID or its URL alias, including its link.

UsepageDetailWhen tagging, you can specifyidortokenPass parameters to locate the target single-page, and throughname="Link"Pass parameters to extract its URL.

Here is an example of calling a specific single-page link:

{# 假设我们已知“关于我们”页面的ID是1 #}
<a href="{% pageDetail with name='Link' id='1' %}">关于我们</a>

{# 假设“联系我们”页面的URL别名(token)是“contact-us” #}
<a href="{% pageDetail with name='Link' token='contact-us' %}">联系我们</a>

{# 您也可以将链接赋值给一个变量,再使用 #}
{% pageDetail aboutUsLink with name='Link' id='1' %}
<a href="{{ aboutUsLink }}">关于我们</a>

In these examples,name='Link'Make it clear to the Anqi CMS template engine that we want to retrieve the external link of this single page.The system will automatically generate a complete and accessible URL based on the "custom URL" in the background and the website's pseudo-static rules.

List of links to batch call single pages

If you need to display multiple single-page links in a loop, such as in a sitemap or a 'Featured Pages' list,pageListtags will be your ideal choice.pageListThe tag will return an array object containing all single page information, you can traverse it byforand get the link of each single page.

This is an example of calling a batch of single page links

<nav class="footer-pages-nav">
    <ul>
        {% pageList pages %}
            {% for item in pages %}
                {# item.Link 会输出当前单页面的链接 #}
                <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
            {% endfor %}
        {% endpageList %}
    </ul>
</nav>

In this example,pageListAll available single pages were retrieved,for item in pagesThe structure then processes each single page in order.{{ item.Link }}The variable will output the URL of the current single page in each loop, while{{ item.Title }}it will output the page title, making it convenient for you to build a dynamic page list.

an important consideration when calling the template

When calling single-page links in templates, there are several practices and backend configurations that you need to pay attention to in order to ensure the accuracy of the links and the overall performance of the website:

first, Custom URL settingsDetermines the link form of a single page. In the "Page Management" of AnQi CMS backend, each single page can be set to have a "Custom URL".This setting will directly affectpageDetailandpageListLabel outputLinkValue, it is recommended that you set a concise and meaningful custom URL for important pages, which is very beneficial for SEO optimization and user memory.

secondly,The use of single-page template filesIt is also a key point. Anqi CMS allows you to specify custom templates for single pages, such aspage/detail.htmlAs the default template, orpage/{单页ID}.htmlEven manually specified in the backgroundpage/about.html.LinkThe tag outputs the URL to access these pages, not the path to the template file itself.

Finally, if you are operating AnQi CMS in a multi-site environment and need to refer to single-page links from other sites,pageDetailandpageListtags are supportedsiteIdparameter. ThroughsiteIdYou can explicitly specify which site to fetch single-page data from, thereby realizing cross-site link calls.

By using the above method, you can flexibly and efficiently call single-page links in the Anqi CMS template, whether it is a precise reference to a single page or a list display of multiple pages, it can be easily realized, thereby enhancing the overall navigation and user experience of the website.


Frequently Asked Questions (FAQ)

Q1: What should I do to troubleshoot the issue of my single-page link not displaying correctly in the template?

A1: If the single page link is displayed incorrectly, please first check if the "Custom URL" setting of the single page in the "Page Management" section of the Anqie CMS backend meets your expectations, as this is the basis for generating links.Next, go to the "Function Management" under the "URL Rewrite Rule" page, confirm whether the URL rewrite rule of the single page is correctly configured and effective.Incorrect pseudo-static rules may cause links to be incorrectly parsed.

Q2: Can I display a single page link with a specific ID or under certain conditions within a loop?

A2: Absolutely. When usingpageListAfter getting the list of single-page tags, you canforcombine within the loopifFilter tags logically. For example, you can write the code to display only single-page links with ID 5 and ID 10:

{% pageList pages %}
    {% for item in pages %}
        {% if item.Id == 5 or item.Id == 10 %}
            <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
        {% endif %}
    {% endfor %}
{% endpageList %}

Q3: How to insert images or videos into a single page and call these media contents in the template?

A3: The main content of a single page (ContentField) is edited through the rich text editor in the background. You can directly insert images or videos in the editor. If the page is configured with media resources such as "Banner image" or "thumbnail", you can use them in the template.pageDetailLabels to call them. For example, `

Related articles

How to obtain the SEO title and description of a single page through template tags?

As an experienced security CMS website operator, I am well aware of the key role that each page plays in search engine optimization, especially the SEO title and description.They are not only the first line of defense to attract users to click, but also an important signal to convey the core content of the page to search engines.AnQi CMS is well-versed in this, providing us with powerful and flexible template tags, allowing us to precisely control the SEO elements of each single page.

2025-11-06

How to use the lazy loading feature of images in single page content?

As an experienced AnQiCMS website operator, I know the importance of website performance for user experience and SEO.Lazy loading of images is an essential optimization method to improve website loading speed, especially on single-page content that contains a large number of images.AnQiCMS provides good support for lazy loading of images at the content rendering level, allowing us to implement this feature through simple template configuration combined with front-end technology. I will elaborate in detail on how to implement lazy loading of images in the single-page content of AnQiCMS.

2025-11-06

How to determine if a single page exists in the template and display its content?

As an experienced security CMS website operator, I know that it is crucial to flexibly control the display of content in template development, especially for single-page content such as "About Us" and "Contact Us" that may require dynamic judgment and display.In actual operation, we often need to decide whether to render a block or link based on the existence of the page to ensure the accuracy of the website content and the user experience.Below, I will elaborate on how to determine if a single page exists in the Anqi CMS template and display its content.###

2025-11-06

How to retrieve the list of all single pages using the `pageList` tag and display it on the front end?

As a senior person who is deeply familiar with AnQiCMS (AnQiCMS) operation, I know that content is the core position in website construction.The single page acts as the cornerstone for carrying corporate core information, service introduction, contact information, and other static content. Its effective display is crucial for users to understand the website and the corporate image.This article will elaborate on how to use the built-in `pageList` tag of AnQiCMS to retrieve and flexibly display all single page content on the frontend.### Master the `pageList` tag to build a clear single-page navigation and display In AnQiCMS

2025-11-06

Can the creation time or update time of a single page be retrieved and displayed?

In the operation practice of Anqi CMS, we often pay attention to the time information of the release and update of website content.This is crucial for search engine optimization (SEO) and for users to understand the timeliness of content.Whether the creation time or update time of a single page (Page) can be obtained and displayed, a detailed analysis based on the document provided by Anqi CMS can lead to a clear conclusion.The 'Page Management' feature of AnQi CMS is mainly used to create and manage independent static content pages, such as 'About Us', 'Contact Information', etc.

2025-11-06

How to call single page data from other sites in a multi-site environment?

As an experienced CMS website operation person, I am well aware of the core position of content in website operation.How to efficiently and flexibly call and manage content in a multi-site environment, especially for single-page data, is a real challenge for many operators.AnQi CMS relies on its powerful multi-site management capabilities to provide us with an elegant solution. ### Content Sharing Strategy in the Multi-site Environment of Anqi CMS From the outset, Anqi CMS has taken into account the needs of enterprises and content operation teams for multi-site management.

2025-11-06

How to configure a canonical URL for a single page to optimize SEO?

As a website operator who has been deeply involved in AnQiCMS for many years, I am well aware of the profound impact that every detail has on SEO optimization in content creation and publication.The canonical URL is one of the often overlooked elements that are crucial for search engine rankings and website health.It can effectively solve the problem of duplicate content, concentrate the page weight, and is an effective tool to improve SEO performance.I will elaborate in detail on how to configure standard links for single pages in AnQiCMS

2025-11-06

How to set up pseudo-static rules for a single-page to optimize URL structure?

As an operator who deeply understands the operation of AnQiCMS, I know that a clear and semantical URL structure is crucial for the website's search engine optimization (SEO) and user experience.Strong static function provided by Anqi CMS, allowing website administrators to flexibly define the URL form of the website.Today, we will delve into how to set up pseudo-static rules for a single-page application to build more attractive and readable URLs.

2025-11-06