How to generate a permanent link to a document in AnQiCMS template: A comprehensive guide from backend configuration to frontend display
In website operation, a clear, easy-to-understand, and SEO-friendly permalink (Permalink) is self-evident in its value.It not only improves user experience, allowing visitors to recognize page content at a glance, but is also the cornerstone of website SEO optimization.A stable and semantically meaningful URL structure can effectively help search engines crawl and understand your content, thereby affecting the ranking performance of the website.AnQiCMS knows this, therefore it provides users with high flexibility and automation capabilities in the generation and management of permanent links.
As an experienced website operations expert, I will guide you to deeply understand how AnQiCMS is configured from the backend to the frontend template presentation, and step by step build your document permanent link system.
1. Static rules for the back-end: lay the foundation for links
The final form of the permanent link, determined first by the website's static rule.The static page technique can rewrite dynamically generated URLs into a static form, which retains the flexibility of dynamic content and also gains the friendliness of static URLs to search engines.
AnQiCMS provides users with a variety of preset static rules, such as 'numeric mode' (using content ID as the URL identifier), 'model naming mode' (using the identifier of the content model), and 'category naming mode' (using the identifier of the content category).These patterns can meet the basic needs of most websites.
However, for users pursuing ultimate SEO optimization or have special business needs, the "custom mode" is undoubtedly a powerful tool.In custom mode, you can freely combine various built-in variables to design a unique URL structure like building blocks.These core variables include:
{id}: Unique numeric ID for documents, categories, or single pages. This is the most stable and direct identifier.{filename}: The custom link name for a document or a single page, usually specified by the user during content editing.{catname}: The custom link name for categories, defined in category management.{module}: The URL alias of the content model, for example, the article model may have an aliasarticle, and the product model may be aliased asproduct.{page}: Used to indicate the page number when there is pagination on the list page.
By flexible combination of these variables, you can achieve such as/article/anqi-cms-template.html//news/category/industry-updates.htmlEven more complex URL structures. The AnQiCMS static rule management interface is intuitive and easy to use, allowing you to easily adjust and preview URL effects without touching any code.Reasonably plan your pseudo-static rules, which is the first step to building efficient permanent links.
2. In content editing, 'Custom URL': gives content personal identification
Relying solely on the global pseudo-static rules may not meet all personalized needs.AnQiCMS provides a 'Custom URL' feature on the content editing level, allowing each content unit to have a more descriptive or brand-characteristic dedicated link.
Whether it is to publish articles, create categories, or edit independent pages or tags, you can find an input box named "Custom URL" in the corresponding management interface. This field allows you to specify a unique identifier that is easy to remember and spread for specific content units, which is usually used in your pseudo-static rules.{filename}or{catname}Variables correspond.
For example, you have an article about "AnQiCMS template development skills", and the system may automatically generate a custom URL for it.anqicms-moban-kaifa-jiqiaoBut if you want to optimize it to be more concise and keyword-richanqicms-template-devYou can manually modify this field. It is worth noting that the custom URL must ensure uniqueness throughout the site to avoid link conflicts. If the manually entered value is duplicated, the system will append random numbers to ensure uniqueness.
By carefully setting up a custom URL, you can give each piece of content a permanent link that conforms to the overall rules and has both personalization and SEO advantages.
3. Call in the template: Easily present permanent links
Once the background static rule and the custom URL setting of the content are properly set, it becomes very intuitive and simple to call and display these permanent links in the AnQiCMS template, without the need for complex URL concatenation or dynamic parsing.
All content tags of AnQiCMS (such asarchiveListUsed to get document lists,archiveDetailUsed to obtain document details,categoryListUsed to get category lists,pageListUsed to get single page lists,tagDetailUsed to get tag details, as well asnavListUsed to get the navigation list, etc.) will directly provide a namedLinka field that containsLinkThe field already contains the complete, accessible permanent link generated based on the pseudo-static rules and content custom URL configured on your backend.
This means, you just need to simply refer to thisLinkfield, for example:
- When outputting the article list in a loop, the permanent link of each article can be presented by
{{ item.Link }}. - When displaying the detail page of the current article, the permanent link of the article itself can be accessed through
{% archiveDetail with name="Link" %}Get it. - The logic of the link on the category, single-page, or tag page is the same, just call it in the corresponding tag
Linkthe field.
{# 示例:在文章列表中调用每篇文章的永久链接 #}
{% archiveList archives with type="list" limit="10" %}
{% for item in archives %}
<li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
{% endfor %}
{% endarchiveList %}
{# 示例:在文章详情页调用当前文章的永久链接 #}
<link rel="canonical" href="{% archiveDetail with name="Link" %}" />
This design greatly simplifies the work of template developers, encapsulating the complex logic of URL generation in the system's underlying layer, allowing the front end to focus only on the presentation of content, ensuring the correctness and consistency of URL output.
Summary: Link management that is flexible and efficient at the same time
In summary, AnQiCMS combines the flexible static rule configuration of the backend with the custom URL editing on the frontend content, to build a high-efficiency, easy-to-use and SEO-friendly permanent link management system.Whether it is a site administrator or a template developer, both can easily manage and present URLs with good user experience and search engine performance within their respective responsibilities.With the powerful 301 redirect management function of AnQiCMS, even if the URL structure has to be adjusted due to business development, it can effectively avoid dead links and protect the SEO assets of the website.This comprehensive and detailed consideration is exactly the value of AnQiCMS as a senior content management system.
Frequently Asked Questions (FAQ)
Q: After changing the pseudo-static rules in the background, will the old document links become invalid immediately? Do I need to update them manually? A:The strength of AnQiCMS lies in its built-in 301 redirect management.After you change the static rule in the background, the system usually automatically handles the redirection of old links, ensuring that users accessing old URLs can be smoothly redirected to new URLs, thereby avoiding link failure and SEO weight loss.But to ensure that everything is in place, after adjusting the rules, you can check and manually add the necessary through the '301 Redirect Management' in the 'Function Management' of AnQiCMS to cover any special cases that may exist.
Q: 'Custom URL' field is mandatory? What if it is left blank? A:The "Custom URL" field is not a required item. If you choose to leave it blank, AnQiCMS will automatically generate a link identifier based on the static rules configured in the background, combined with the title of the content (through pinyin conversion, etc.).For example, if your static rules include
{filename}Variable, the system will automatically generate a pinyin version of the filename.Although the system automatically generates enough intelligence, manually optimizing this field can make it more semantically meaningful and keyword relevant, which is more beneficial for SEO.Q: Can I manually concatenate the URL in the template, such as?
/article/{{item.Id}}.htmlIs it? And with using{{ item.Link }}What is the difference? A:In theory, you can manually concatenate, but it is strongly recommended not to do so.Directly concatenating the URL will lose the flexibility of AnQiCMS's pseudo-static rules and the advantages of centralized management in the background.When you change the pseudo-static rules, manually concatenate