In daily website content operations, we often need to include various links in articles or descriptions, whether they point to other pages within the site or external references.One of the key factors of user experience is that these URL strings can automatically become clickable hyperlinks, rather than a string of cold text.AnQiCMS (AnQiCMS) fully understands this and provides a variety of flexible and efficient methods to help ensure that URLs in the content can be intelligently converted into clickable hyperlinks.

Next, we will discuss how to achieve this goal in AnQiCMS, making your content more interactive.


Using Markdown editor: A powerful tool for modern content creation

AnQi CMS has built-in support for Markdown syntax, which is a lightweight markup language that allows us to write in a concise plain text format and control the style of content with simple symbols, including inserting hyperlinks.When you enable the Markdown editor while creating content, the automatic conversion of URLs will become extremely simple.

You can create clickable links in Markdown in the following two main ways:

  1. Explicit linkThis is the most common Markdown link form, you can write the display text of the link in square brackets[]then in the following round brackets()Enter the URL address. For example:[访问安企CMS官网](https://en.anqicms.com)It will display on the page as “Visit AnQi CMS official website” and can be clicked to jump.

  2. Automatic link:A simpler way is, if you directly enter a complete URL string in the Markdown content (for example, withhttp:///https://orwww.The address at the beginning), Markdown editors usually automatically recognize it and convert it into a clickable hyperlink without any additional tags. For example:https://en.anqicms.comorwww.anqicms.comIn most cases, it will be automatically recognized and converted to a hyperlink.

To enable the Markdown editor, you need to make simple configurations in the AnQiCMS backend. Usually, this will be located in全局设置below内容设置where you can find是否启用Markdown编辑器The option. Check and save it, and your content editing area will have Markdown parsing capabilities, making it possible for automatic URL conversion.

Use template filtersurlizeandurlizetrunc: The intelligent conversion behind the scenes

Sometimes, the content is not created through the Markdown editor, or you want to automatically convert URLs in some plain text fields (such as descriptions, custom parameters, etc.). At this time, the AnQiCMS template filterurlizeandurlizetruncIt comes into play. These filters can intelligently scan text when the content is output to the front-end page, identify URLs or email addresses, and automatically wrap them into clickable links.<a>.

  1. urlizeFilterThis filter will find all text that starts withhttp:///https:///www.The URL at the beginning, as well as legitimate email addresses, will be converted into standard HTML hyperlinks. It will even automatically add hyperlinks to these automatically generated links.rel="nofollow"Property, this is very useful for SEO optimization and preventing the transmission of weight through spam links. The method of use is usually in the template file, for the text content that needs to be output (such as the article detail page of the{{ archive.Content }}Or other descriptive fields) apply this filter. For example:{{ archive.Description|urlize|safe }}. Here,|safeIt ensures that HTML code is not doubly escaped and can be displayed correctly.

  2. urlizetruncFilter: Function andurlizeSimilar, but it goes further, allowing you to specify the maximum length of the text displayed for the link. If the original URL string is very long,urlizetruncit will truncate it and add an ellipsis at the end (...),to maintain the page layout neat, while retaining the integrity of the links. Usage:{{ archive.Description|urlizetrunc:30|safe }}. This example shows that if the link text exceeds 30 characters, it will be truncated.

These filters are very suitable for handling content areas that may contain URLs but do not want users to manually edit them into links, such as user comments, automatically crawled content, etc.They are equivalent to applying an intelligent processing layer on the content display level, greatly improving the readability and user experience.

Rich text editor: manually controlled precise links

Of course, in addition to the two automatic conversion mechanisms mentioned above, AnQiCMS' WYSIWYG rich text editor also provides intuitive toolbar buttons for manually inserting and editing hyperlinks.When you need to link specific text in content and want to precisely control the display text, URL, and whether it opens in a new window, manually inserting a link is still the most direct and effective way.This usually applies to scenarios that require highly customized link display or to perform anchor text link operations on some keywords.


In summary, AnQiCMS provides intelligent parsing from the front-end editor to the automatic conversion of back-end templates, and multiple ways to ensure that the URL strings in your website content can be effectively converted into clickable hyperlinks.You can choose the strategy that suits you best according to the content source, editing habits, and page display requirements.No matter which method you choose, it is imperative to preview and test the content after publication to ensure that the links jump normally and provide a smooth experience for users, which is the foundation of successful content operation.


Frequently Asked Questions (FAQ)

1. Why doesn't my Markdown link or directly entered URL automatically become a clickable hyperlink?

This usually has several reasons. First, please check the AnQiCMS background.全局设置-u003e内容设置,是否启用Markdown编辑器The option has been checked. If it is not enabled, Markdown syntax will not be parsed. Next, check if your Markdown syntax is correct. Explicit links require[显示文本](URL)The format, while automatic links require the URL to be complete (for example, starting withhttp://orwww.). Finally, if you have output content in the template but have not used|safeFilter, the original HTML code may be escaped, causing the link to not render correctly.

2. UseurlizeAfter the filter, the link will be automatically added.rel="nofollow"What is the impact?

Yes,urlizeThe filter automatically adds when converting URLs to hyperlinksrel="nofollow"The attribute tells the search engine not to follow this link and not to pass any 'weight' or 'trust' to it.This is very beneficial in avoiding search engines from misjudging automatically generated, unreviewed links as cheating behavior, as well as preventing spam links from passing on weight.If you need to pass weight to some links or be tracked by search engines, you should avoid using themurlizeThe filter, and manually create these links in the rich text editor.

3. Where can I find or modify the template file to applyurlizeFilter?

You can find it in the AnQiCMS background.模板设计-u003e模板管理Find and edit the template file of the website. Usually, you need to find the corresponding template that displays the article or page content (such asarchive/detail.htmlUsed for the article detail page, or for custom content model corresponding templates). In these template files, find the variables for outputting text content (like{{ archive.Content }}or{{ item.Description }}), and then add it after it|urlizeor|urlizetrunc:数字Filter and remember to add|safeTo ensure correct HTML parsing, for example{{ archive.Content|urlize|safe }}. If you are not familiar with template editing, you can refer to模板设计below模板开发文档For more detailed guidance.