How to display the article summary instead of the full text on the search results page?

How to let users quickly understand the article content on the search results page while not displaying the full text, which is not only related to user experience but also a key link in Search Engine Optimization (SEO).For those who use AnQiCMS, achieving this is very flexible and efficient.

In English, when we want to display a list of articles on the search results page, if we directly present the full content of the articles, it not only leads to a long page that is difficult for users to quickly browse, but may also cause a large amount of duplicate content, negatively affecting the SEO performance of the website.Search engines tend to display refined summaries on list pages and encourage users to click through to the detail page for complete information.

The Anqi CMS has fully considered the flexibility of content display and SEO-friendliness from the very beginning.It allows us to precisely control the content segments displayed on different pages.To make the search results page display the article summary instead of the full text, it mainly involves modifying specific template files.

The importance of understanding the article summary

In the Aanqi CMS, each article has a 'Document Summary' field.This field is specifically used to store a brief overview of the article.Its function is like the advertising language on the cover of a book, it needs to be attractive enough and accurately convey the core content of the article.

When you publish or edit articles in the background "Content Management", you will see the "Document Summary" area.The CMS is very intelligent: If you manually fill in the introduction, the system will prioritize it; if you do not fill it in, the system will automatically extract content from the first 150 words of the article body as the introduction.

  1. Improve click-through rate (CTR): A catchy summary can better catch the user's attention and make them interested in clicking into the detail page.
  2. Avoid duplicate content: Display a brief introduction on the list page to effectively avoid complete repetition of content with the article detail page, thus optimizing SEO and avoiding penalties from search engines.
  3. Optimize search rankings: The search engine will also refer to the introduction content when evaluating page relevance. High-quality introductions help improve the visibility of articles in search results.

Locate the search results page template

The template files of AnQi CMS are all stored in the system's/templatedirectory. Different page types correspond to different template files. For search results pages, the corresponding template file is usuallysearch/index.html.

If you have deployed AnQi CMS through tools like Baota Panel or 1Panel, you can directly find and edit these files in the "Template Design" feature in the background. Alternatively, you can also connect to the server manually through FTP/SFTP tools./template/您的模板目录/search/index.htmlFile. Please make a backup of the original file before making any modifications, just in case.

Modify the template to display the article summary.

Entersearch/index.html模板文件后,您会发现其中包含了用于循环显示文章列表的代码。安企CMS使用类似Django模板引擎的语法,文章列表通常通过English{% archiveList %}you can get it by tag.

In the loop body{% for item in archives %}you might find something similar to{{item.Content|safe}}This line of code is used to display the full content of the article. Now, we need to replace it with the code to display the article summary.

This may show the full code example originally.

{% archiveList archives with type="page" q=urlParams.q limit="10" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            {# 这里可能是显示全文的代码 #}
            <div>{{item.Content|safe}}</div> 
            {# ... 其他文章信息 ... #}
        </a>
    </li>
    {% empty %}
    <li>
        抱歉,没有找到相关内容。
    </li>
    {% endfor %}
{% endarchiveList %}

This shows the code example after modification to display the article summary.

{% archiveList archives with type="page" q=urlParams.q limit="10" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            {# 修改为显示文章简介,并用 truncatechars 限制长度,同时保证 HTML 安全 #}
            <div>{{item.Description|truncatechars:150|safe}}</div> 
            <div>
                <span>{% categoryDetail with name="Title" id=item.CategoryId %}</span>
                <span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>{{item.Views}} 阅读</span>
            </div>
        </a>
        {% if item.Thumb %}
        <a href="{{item.Link}}">
            <img alt="{{item.Title}}" src="{{item.Thumb}}">
        </a>
        {% endif %}
    </li>
    {% empty %}
    <li>
        抱歉,没有找到相关内容。
    </li>
    {% endfor %}
{% endarchiveList %}

Here are some key points:

  • {{item.Description}}: This is the tag to get the content of the article summary field.
  • |truncatechars:150
  • |safeThis filter is also very important. Because your profile content may contain bold, links, and other HTML tags.|safeThis will inform the template engine that these contents are safe, and do not need to escape HTML tags, ensuring they are displayed normally rather than as plain text.

After modifying and saving the template file, and clearing the website cache (from the backend homepage or the 'Update Cache' feature), refreshing the search results page, you will see that the article list no longer displays the full text but a concise summary instead.

Content operation tips

Since we have adjusted the content display of the search results page to a brief introduction, it is particularly important to make full use of this brief introduction field.

  • Carefully written, avoid emptiness: Even though the summary will be automatically extracted from the main text, manually writing it can make the summary more marketing-oriented and attractive.
  • Integrate keywordsIncorporate core keywords cleverly into the introduction without affecting the reading experience, which helps search engines better understand the article's theme.
  • Regularly review and optimize:Based on the website's traffic statistics and user feedback, regularly check the effect of the article abstract and make necessary adjustments and optimizations.

Through these simple template modifications and content operation strategies, your security CMS website will provide users with a better browsing experience on the search results page, while also effectively improving the website's SEO performance.


Common Questions (FAQ)

Q1:How can I handle it if the introduction of my article is too long or too short?A1:You can use|truncatechars:数字filters in the template to control the display length of the introduction, for example{{item.Description|truncatechars:150|safe}}The summary will be truncated to 150 characters.For the content of the introduction itself, even though the system will automatically extract it, we still recommend that you manually write it in the background to make it concise and attractive, with a length controlled between 50-150 characters to achieve a**display effect.

Q2:In the article list of the category page or tag page, do the operations remain the same?A2:Yes, the operation method is very similar. The category page (usually){模型table}/list.htmlOr custom category templates) and tabs (usuallytag/list.htmlortag/index.html) list of articles also usually uses{% archiveList %}Label to display articles in a loop. Therefore, you only need to find the corresponding position of the article content in these template files (usually{{item.Content|safe}}), and replace it with{{item.Description|truncatechars:150|safe}}.

Q3:If I do not manually fill in the introduction, will the system automatically generate it?A3:Yes, Anq CMS is very intelligent.If you do not manually fill in the 'Document Summary' when publishing or editing an article, the system will automatically extract content from the first 150 characters of the article body as the summary of the article.Although this ensures that each list item has a brief introduction, manually written introductions are often more targeted and attractive, which is more beneficial for SEO and user click-through rate.