As an experienced website operations expert, I know that how to flexibly and efficiently locate and obtain specific content in a content management system is the key to improving operational efficiency and website SEO performance.AnQiCMS provides very practical mechanisms in page management, in addition to the most common method of specifying a single page through ID, there are actually parameters that are more in line with operational thinking that can be utilized.Today, let's delve deeply into this topic.
Advanced Single Page Call of AnQiCMS: In addition to ID, you can also locate content efficiently through these parameters
In Anqi CMS, single pages (such as "About Us", "Contact Us", "Privacy Policy", etc.) are an important part of building website basic information.By default, when we mention locating a single page, most people think of identifying it by its unique numeric ID.This is certainly an accurate way, just like everyone has a unique ID number.However, in the actual operation of websites, pure numeric IDs are often not intuitive and lack SEO-friendliness, especially when developing templates or migrating content, hardcoded IDs are more likely to cause maintenance problems.
Then, besides ID, what "smarter" parameters does Anqi CMS provide to specify the single page to be retrieved? The answer lies in -URL alias (also known as custom URL, usually corresponding to template tags in AnQiCMS)tokenparameters).
URL alias: give a single page a 'unique nickname'
Imagine if you want to refer to the "About Us" page, should you use its ID "123" in the database, or would it be more convenient to use a clear and understandable "about-us"?It is undoubtedly the latter. Anqi CMS is well-versed in this, providing a 'Custom URL' setting for each single page.
This custom URL, which is what we call the URL alias, has the following core features and advantages:
- Intuitive and easy to understand, convenient to remember:Operatives can name page aliases with meaningful English words or pinyin (for example
about/contact-us), which is easier to remember and manage than dull numbers and IDs. - SEO friendly:Search engines prefer URLs with descriptive names, a URL alias containing keywords helps improve the search engine ranking of a page. For example,
yoursite.com/about-us.htmlThanyoursite.com/page-123.htmlmore semantically meaningful. - The template call is flexible:In the template, you can directly use this URL alias to accurately retrieve the content of a specific single page without having to find its ID on the backend.
- Uniqueness guarantee:In Anqi CMS backend, when you set the custom URL for a single page, the system will prompt that the alias must be unique throughout the site.Even if you manually enter a duplicate alias, the system will automatically add a random number after it to ensure uniqueness and avoid content conflicts.
In the AnQi CMS backend management interface, when you edit or create a single page, you will see a 'Custom URL' input box.By default, if you do not fill in, the system will automatically generate a pinyin form of URL alias based on the name of the page you enter.Of course, you can also manually modify it according to your own needs, such as changing it to a more concise, more internationalized English alias.
Pass in the templatetokenPrecision parameter call
Understood the concept of URL alias (custom URL), we can then apply it to template development, realizing that we can obtain single-page data through this "nickname". In the template tag system of Anqi CMS, pageDetailTags are used to obtain detailed information about a single page. Besidesidin addition to the parameters, it also supports a key parameter:token.
tokenThe parameter is used to receive the single-page URL alias set on our backend. When you need to get the data of a specific single-page in the template but it is inconvenient or you don't want to use its ID, you can usetoken.
Example code:Assuming your custom URL for the "About Us" page is set toabout, you want to display its title and content on the page, you can write it like this:
{# 获取URL别名为“about”的单页标题 #}
<div class="page-title">
{% pageDetail with name="Title" token="about" %}
</div>
{# 获取URL别名为“about”的单页内容 #}
<div class="page-content">
{% pageDetail with name="Content" token="about" %}{{ pageContent|safe }}
</div>
In this way, your template code becomes more readable and easier to maintain.Even if the ID of this single-page changes in the future (for example, data migration), as long as the URL alias remains unchanged, your template code will still work normally without any modification.
Differentiate custom template files from page call parameters
It is worth mentioning that Anqi CMS also supports specifying a "single page template" for individual pages (for examplepage/about.htmlThis may raise some doubts among operators: Can I directly specify the single-page acquisition through thisabout.htmlCan I specify the single-page acquisition through the filename
It is necessary to clarify a concept hereThe custom template file determines how to renderThe single-page content you obtain, whileIDandtokenThe parameters determine which single page you are gettingdata.
When you create a namedpage/about.htmlThe template file, and in the background set a single page (such as ID 123, URL alias asaboutThe "About Us" page) single page template to setabout.htmlIt means that when this "About Us" page is visited, the system will usepage/about.htmlThis template is used to display its content. However, in the URL address or template tags, we still need to pass throughID(such asyoursite.com/page-123.htmlortoken(such asyoursite.com/page/about.htmlIf the configuration of the pseudo-static rule allows, it can indicate which page to access, such as the "About Us" page. The template file itself cannot directly "get" the page data as a parameter.
In short,tokenThe parameter (URL alias) is a 'semantic identifier' provided by Anqicms for single pages, which is similar to traditional IDs and can accurately specify the single page you want to retrieve.Use URL aliases wisely, not only can it make your website URL more attractive and improve SEO, but it can also greatly simplify template development and content management work.
Frequently Asked Questions (FAQ)
Ask: URL alias (
token) and ID can locate a single page, which one should I prioritize? Answer:In most cases, it is recommended to prioritize the use of URL alias (tokenIt has better readability, SEO-friendliness, and in the background content adjustment (such as ID changes), as long as the alias does not change, the template code usually does not need to be modified, which is convenient for maintenance.ID is accurate but more biased towards technical identification. It is only considered when the URL alias is uncertain or specific operations need to be performed based on the system internal ID.Ask: If I set a custom URL alias for a single page, will the URL for accessing the single page change? Answer:Will do. Anqi CMS supports pseudo-static rules, when your pseudo-static rules configuration allows the use of URL aliases (for example
page/{filename}.html), set a custom URL alias, and the access address will become likeyoursite.com/page/your-custom-alias.htmlThis is the key role of URL aliases in SEO and user experience. Be sure to configure the "pseudo-static rules" correctly in the background.Ask: Can I set multiple URL aliases for the same single page in the background? Answer:Cannot. Each single page can only have a unique URL alias. Anqi CMS strictly requires the uniqueness of URL aliases to avoid ambiguity when the system parses requests