In the daily operation of websites, we often need to insert various URLs in the article content, whether it is to reference external resources or to guide users to visit other pages within the site. If we always add these URLs manually,<a>

核心机制:让内容中的URL“活”起来

When you edit articles, single pages, or category content in the AnQiCMS backend, whether you input it through the rich text editor or paste plain text, if you want the URL strings contained within to be automatically converted into clickable links, it is mainly achieved through the 'Filters' on the template level.

AnQiCMS's template engine supports powerful filter functions, whereurlizeandurlizetruncthese two filters are specifically designed to handle such needs.

urlizeFilterIts function is very direct and powerful, when you apply the contenturlizeWhen using the filter, AnQiCMS will intelligently scan the text, automatically identifying strings that match the URL format (includinghttp://orhttps://Starting URLs,www.The domain at the beginning, even an email address), and it is automatically wrapped in HTML's<a>Make it clickable link in the tag.

It is also worth mentioning that, in order to better support SEO,urlizeThe filter will also automatically add to the external links it generatesrel="nofollow"Property.This means that even if you forget to manually add, AnQiCMS will automatically inform search engines not to track these links, thereby helping you better manage the external link weight of your website.

For example, in your template file, if you want the article content (usually stored inarchive.ContentThe URL in the variable is automatically made clickable and safely displays HTML, and you just need to write it like this:

{{ archive.Content|urlize|safe }}

Here are the|safeIt is essential, as it tells the template engine that this content is safe HTML and does not need to be escaped, thus allowingurlizegenerated<a>tags to be displayed normally.

urlizetruncFilterIn some cases, the URLs that appear in the article may be very long, which may affect the aesthetics and reading experience of the page. In this case,urlizetruncthe filter comes into play. It isurlizeon the basis of, an truncation feature has been added, you can specify the maximum display length of the link text. If the length of the URL exceeds this limit, the extra part will be omitted with an ellipsis (...The actual link is still complete instead of }"),

For example, if you want the link text to display a maximum of 15 characters, you can use it like this:

{{ archive.Content|urlizetrunc:15|safe }}

This is very useful for keeping the page tidy, especially when the content contains a large number of long URLs.

Advanced Application: Smart Anchor Text and Full Site Link Management

AnQiCMS not only stops at simple URL auto-conversion, it also provides a set of more advanced link management features, which can push content operation to a new height:

  1. English Anchor Text FunctionIn AnQiCMS backend, you can configure a 'keyword library' and 'anchor text management' feature.Here, you can preset a series of keywords and their corresponding target URLs.When you publish an article, AnQiCMS can automatically scan the content of the article. If it finds keywords you have preset in the text, it will automatically convert them into anchor text links pointing to the corresponding URL.This is of extraordinary value for constructing a strong internal link structure, improving the website's SEO ranking and user navigation experience.It has achieved a smart leap from 'no link' to 'with link', without the need for human intervention, greatly reducing the operational burden.

  2. full-site content replacement:If you need to batch update a URL on the website, or replace an old keyword with a new one and include a link, AnQiCMS's 'Full Site Content Replacement' feature can be done with one click.This avoids the麻烦 of page-by-page modification, ensuring the efficiency and accuracy of link updates.

  3. Static URL and 301 Redirect Management

The value behind it: improving user experience and SEO performance

For website operators, these features of AnQiCMS mean:

  • Time-saving and labor-saving:Saying goodbye to the repetitive labor of manually adding links, focus your energy on content creation itself.
  • Enhance user experience:Content within the URL automatically becomes clickable, allowing users to directly jump to the link without copying and pasting, for a smoother reading experience.
  • Optimize SEO effect:Generated automaticallynofollowProperties, effective control of external link weight; enhance the rationality and density of internal links through intelligent anchor text, improve page weight and keyword ranking.
  • Content management more efficientWhether it is batch updating links or adjusting keyword strategies, it can quickly respond through the backend functions to keep the website content up-to-date and in English.

In summary, AnQiCMS provides a comprehensive solution for users through built-in template filters and a series of powerful backend management features, from basic URL automatic parsing to advanced anchor text intelligent generation, and full-site link maintenance, making link management in content unprecedentedly simple and efficient.


Common Questions (FAQ)

  1. Why doesn't the front-end automatically turn the URL I input directly in the article into a clickable link?This is usually because you did not apply the filter to the variable containing the URL when displaying the article content in the template file.urlizeorurlizetruncCheck your template code to make sure it looks like{{ archive.Content|urlize|safe }}This usage is added correctly, wherearchive.Contentis the HTML content variable you need to parse.

  2. urlizeWhat is the difference between the filter and the "anchor text management" in the background? urlizeFilter is mainly aimed at the existing contentPlain text URL string(such ashttp://www.example.com) for recognition and automatically converted into clickable links, and automatically addednofollowThe attribute focuses on the format of the URL itself. While 'Anchor Text Management' is a more advanced SEO tool, it allows you to preset in the backgroundKeywords(such as "AnQiCMS function") and corresponding target links, the system will automatically convert the matched keywords in the article into links pointing to the pages you specify when publishing content.It focuses on converting specific text into links to enhance internal link and keyword weight.

  3. I can be inurlizeDo you want to customize other HTML attributes in the links generated by the filter? urlizeThe filter will automatically add it to the external links by default.rel="nofollow"Property, currently does not support customizing other HTML attributes through parameters.If you need more precise control, you can consider manually inserting HTML links in the content editor, or through the 'Anchor Text Management' feature of AnQiCMS, which allows you to define target URLs for keywords, thus achieving a certain degree of customized management of links.