Make good use of AnQiCMSwordcountFilter, accurately control the keyword density of page titles and descriptions
The importance of page title (Title) and description (Description) in the practice of website operation and search engine optimization (SEO) is self-evident.They are not only the information that users see first in search results, directly affecting the click-through rate, but are also the key signals that search engines understand the core theme of the page content.To make the page stand out among competitors, it is an effective means to improve the relevance score of the page by reasonably controlling the keyword density in the title and description and ensuring the effective appearance of the core keywords.
AnQiCMS as a SEO-friendly and powerful content management system, provides a rich set of template tags and filters to help users finely manage website content. Among them,wordcountThe filter is a powerful tool we use to monitor and optimize the keyword density of page titles and descriptions.
UnderstandingwordcountThe filter and its function
wordcountThe filter plays a concise and practical role in the AnQiCMS template engine: it is used to count the number of words in a given string.Here the 'word' is separated by spaces.wordcountThe filter counts 7 words ("AnQiCMS", "is", "a", "content", "management", "system").
Its basic usage is very intuitive:{{ 您的变量|wordcount }}.By passing the text content of the page title or description as a variable, we can get the total number of words it contains.This provides basic data for us to calculate the proportion of keywords in the overall text (i.e., keyword density).
Use it in the page title.wordcountFilter
The page title is usually one of the most important SEO elements of a website.It is directly displayed in the browser tab and search results.To optimize the keyword density of the title, we need to ensure that the core keywords appear at a natural frequency and that the overall length of the title is moderate.
In AnQiCMS, the page title is usually set through the universal TDK tag{% tdk with name="Title" %}Get it. To calculate the word count of this title, we can implement it in the template file in the following way:
{% set pageTitle = tdk.Title %} {# 获取页面标题的实际内容 #}
<title>{{ pageTitle }}</title>
<meta name="keywords" content="{{ tdk.Keywords }}">
<meta name="description" content="{{ tdk.Description }}">
{# 在页面的某个隐蔽处或调试模式下输出标题词数,方便查看 #}
<!-- 页面标题词数:{{ pageTitle|wordcount }} -->
Through such settings, when you view the page source in the browser, you can see the actual word count of the title.Combine the search engine's suggestions for title length (for example, Chinese titles should be about 30 characters long, and English titles should be about 60 characters long), as well as the number of times you expect your keywords to appear, you can flexibly adjust the title content to make it comply with SEO standards and also attract user clicks.
For example, if you want to ensure that the core keyword "安企CMS" appears once in the title and the total number of words in the title does not exceed a certain range,wordcountit can quickly verify it for you.
Use in page descriptionwordcountFilter
The page description does not directly affect ranking, but its content will be displayed as part of the search results summary to users, and is a key factor in improving click-through rate (CTR).An attractive description that includes core keywords, effectively guiding users to visit your website.At the same time, a reasonable keyword density can also help search engines understand the theme of the page.
In AnQiCMS, the content of the page description is through{% tdk with name="Description" %}Tags obtained. Similar to the title usage, we can calculate the word count of its:
{% set pageDescription = tdk.Description %} {# 获取页面描述的实际内容 #}
<meta name="description" content="{{ pageDescription }}">
{# 在页面的某个隐蔽处或调试模式下输出描述词数 #}
<!-- 页面描述词数:{{ pageDescription|wordcount }} -->
Search engines usually have recommendations for the length of descriptions (for example, Chinese is recommended to be between 80-120 characters, and English is recommended to be between 150-180 characters). Too long or too short may affect the display effect. BywordcountFilter, you can check if the description is within the recommended word count range, and consciously integrate core keywords naturally, aiming to achieve a keyword density of 1%-3%, enhancing the relevance and attractiveness of the description.
Suggested actions and **practice
- Keywords naturally integrated:The goal of keyword density is to enhance relevance, not to clutter. Make sure the title and description read naturally and smoothly, accurately convey the page theme, and prioritize user experience.
- Moderate adjustment:
wordcountThe filter provides statistics to help you judge whether the current content meets your expectations. Adjust the title and description based on the data, add or remove words, until reaching **status**. - Combine content management backend:AnQiCMS in the background "Home TDK Settings" and article, category, single page editing interface all provide title, keyword and description entry. You can directly input and modify the content here, and then use it in the front-end template.
wordcountPerform validation. - Consideration of dynamic and static pages:For dynamically generated pages (such as article detail pages), the title and description are usually extracted from the article content. You can flexibly use variables in the template to first assign the extracted content to a variable, and then use the variable for
wordcountFilter. - Combine with other filters:If you want the title or description to be within a specific length range, you can use them together:
truncatecharsortruncatewordsetc., to ensure that the output content is not too long.wordcountResponsible for statistics,truncateresponsible for controlling length.
PasswordcountFilter, AnQiCMS users can manage page titles and descriptions more accurately and scientifically, thereby winning better search engine visibility and user attention.
Common Questions (FAQ)
1.wordcountHow does the filter support Chinese vocabulary? Can it recognize Chinese word segmentation?
wordcountFilter primarily separates "words" based on spaces.For Chinese, as there are usually no spaces between characters, it considers a whole segment without spaces as a 'word'.For example, "Anqi CMS is an efficient system" will be counted as 1 word.make_listThe filter converts to a character array, then useslengthThe filter counts the length of the array, for example{{ "安企CMS"|make_list|length }}It will return 5.
2. Can I see the word count of the title or description directly on the editing interface of AnQiCMS?Currently,wordcountThe filter is mainly used for dynamic statistics and display at the template level.AnQiCMS back-end editing interface usually provides character count (not word count) to help users control the length of text.If you need to see the word count directly in the background, this may require secondary development or outputting to the front-end page in the template.
3. BesideswordcountEnglish, AnQiCMS has what auxiliary SEO filters that can help me control the length of page titles and descriptions?AnQiCMS providestruncatecharsandtruncatewordsFilters, they are very suitable for controlling text length:
truncatechars:number:Truncate strings by character count, with the excess portion displayed as an ellipsis (…).truncatewords:numberEnglish: Truncate the string by word count, and the part exceeding will be displayed with an ellipsis (…).These filters ensure that your title and description are within the recommended length for search engine suggestions, avoiding truncation due to excess length while maintaining readability.