AnQiCMS pagination tags and custom URL structure:prefixParameter in-depth analysis
As a senior website operations expert, I know that a clear, SEO compliant, and user-friendly URL structure is important for a website.How to flexibly control pagination links in content management systems is a common concern for operators.AnQiCMS (AnQiCMS) took this into consideration from the outset, providing website administrators with a great deal of freedom through its powerful template engine and pseudo-static features.Today, let's delve into how AnQiCMS's pagination tag supports custom pagination URL structure, as well asprefixThe specific usage of parameters.
The foundation of AnQiCMS custom pagination URL capabilities
Yes, the pagination tag of AnQiCMS (AnQiCMS) indeed supports custom pagination URL structure.This feature is crucial for the website's search engine optimization (SEO) and user experience.A well-structured and semantically clear URL can not only help search engines better understand page content, improve crawling efficiency and ranking, but also allow users to see the page hierarchy at a glance, enhancing the overall professionalism of the website.The core of achieving this custom capability in AnQiCMS template system is the pagination tagpaginationofprefixParameter.
Deep understandingprefixParameter: The core of custom pagination URL
prefixThe parameter ispaginationA high-level feature provided by the tag, which allows you to precisely define the pattern of pagination links, no longer limited to the system's default rules. By settingprefixYou can transform the pagination link from a simple query string format (such as?page=2) into a more semantically meaningful directory structure (such as/list-2.html), or even other complex custom patterns.
prefixThe key is that you must include the value in the parameter{page}this placeholder.AnQiCMS's template engine will intelligently recognize this placeholder and replace it with the corresponding page number when generating actual pagination links.
Let's understand through several specific examplesprefixUsage:
Custom in query string format: Assuming you want the page number parameter of the pagination link to be non-default
pageit is notpand hope it always appears in the form of a query string. You can set it like thisprefix:{% pagination pages with show="5" prefix="?p={page}" %} {# ... 分页链接循环 ... #} {% endpagination %}So, the link to the second page might be
example.com/article/list.html?p=2.Customized in the form of a directory structureIf your website aims for a flatter or more semantic URL structure, you hope that pagination links can be integrated into the path like static pages, for example
/list-2.html.Combined with the powerful pseudo-static rules configuration of AnQiCMS,prefixParameters can come into play:{% pagination pages with show="5" prefix="/list-{page}.html" %} {# ... 分页链接循环 ... #} {% endpagination %}At this time, the link to the second page may be rendered as
example.com/category/news/list-2.htmlThis looks more aesthetically pleasing, and it is also more friendly to search engines.Custom in complex paths: Even in more complex URL paths,
prefixAlso plays a role. For example, if you have a list page with a date parameterexample.com/archives/2023/10/and want to add pagination on top of that, you can define it like thisprefix:{% pagination pages with show="5" prefix="/archives/2023/10/page/{page}/" %} {# ... 分页链接循环 ... #} {% endpagination %}Such a link might be
example.com/archives/2023/10/page/2/.
It should be noted that the document mentionsprefixIt is a "advanced feature, generally does not need to be set". This means that in most standard application scenarios, AnQiCMS's default pagination URL generation mechanism or through background pseudo-static rules (such ascategory===/{module}-{filename}(-{page})pass through(-{page})Control the pagination part) will meet the needs. Only when you have very special URL naming conventions, or need to override the specific page pagination link generation logic, do you need to use itprefixParameter.
Pagination Labelpaginationthe comprehensive application of
paginationtags not only providedprefixUsed to customize the URL structure, it also includes a series of parameters and available fields, allowing you to fully control the pagination display logic and style. In additionprefix, you may also need to useshowParameters to control the number of page numbers displayed on the page, for exampleshow="5"Up to 5 page number links will be displayed.
When you define it in the template,{% pagination pages ... %}after,pagesA variable will become an object containing all pagination information, the most important of which is the corresponding page number for eachLinkfield. No matter how you setprefix,pagesWithin the objectFirstPage.Link/PrevPage.Link/NextPage.Linkas well asPagesEach element in the arrayitem.Linkit will strictly follow the one you pass throughprefixThe defined URL structure.
For example, a typical pagination loop might look like this, including thehref="{{item.Link}}"will be used automaticallyprefixcustom URL defined:
<div class="pagination">
{% pagination pages with show="5" prefix="/articles/p-{page}.html" %}
<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>
In this way, you can easily design unique pagination URL structures for different content lists on your website (such as article lists, product lists, Tag lists, etc.), thus better serving your operational objectives.
Summary
AnQiCMS'paginationPage label passedprefixParameters, provide website operators with powerful custom pagination URL structure capabilities.This not only demonstrates the advantages of AnQiCMS in terms of SEO-friendliness and customizability, but also makes the website more flexible in URL management, able to meet various complex business and marketing needs.Reasonably utilizing this feature will help enhance the overall quality and user experience of the website.
Frequently Asked Questions (FAQ)
- Q: If not set
prefixParameter, what will AnQiCMS's pagination URL be like? A:If not setprefixParameter, AnQiCMS will automatically generate the default pagination URL based on the structure of the current page URL and the global pseudo-static rules configured in the background. For example, if the current page is a category list pageexample.com/category/news.htmlThen the link to the second page might beexample.com/category/news-2.htmlIf the rule for pseudo-static pages is used(-{page})) orexample.com/category/news.html?page=2(If used in query string format), it depends on the pseudo-static configuration in the AnQiCMS backend.prefixProvided finer, page-level control to override these default behaviors