In website operation, the title of the article detail page is,<title>Tags are crucial for Search Engine Optimization (SEO).A well-designed title can not only increase the click-through rate of the article in the search results, but also help search engines better understand the content of the page.AnQiCMS provides a flexible mechanism, allowing you to easily customize the display format of the article detail page title according to your own SEO strategy.
This article will introduce in detail how to adjust the title of the article detail page in AnQiCMS to meet different SEO requirements.
一、Understanding AnQiCMS title structure
In AnQiCMS, the title of the article detail page usually consists of several parts, such as the article title, the name of the category it belongs to, and the name of the website. By default, AnQiCMS will automatically generate it based on the content you fill in when publishing the article and the global system settings.<title>Label.
AnQiCMS provides a universal tag specifically used to control page title, keywords, and description (TDK)tdk.This tag is the core tool for displaying custom title formats.Moreover, when editing each article in the background, you can set a 'SEO Title' field, which gives you the ability to define an independent title for a specific article.
Second, use the SEO title field of the article itself
The most direct and highest priority way to customize the title is to use the "SEO title" field of each article.
When you publish or edit an article, you will see an 'SEO title' input box within the collapsible box labeled 'Other parameters'.[en]Operation method:
- Log in to the AnQiCMS backend.
- Go to 'Content Management' -> 'Document Management'.
- Click 'Add new document' or edit an existing document.
- On the document editing page, find the 'Other parameters' section and expand it.
- In the 'SEO Title' field, enter the title you want to display on the article detail page.
<title>The full title in the tags.
Effect:If you enter content here, AnQiCMS will prioritize this field as the title of the article detail page and ignore the default article title.This is very suitable for scenarios where highly optimized SEO titles that may slightly differ from the actual article title are needed for specific articles.
3. Adjust the TDK tags in the template file.
If your title strategy requires more global or dynamic control (for example, all articles follow the format "Article Title - Category Name - Website Name"), then you need to modify the template file.
AnQiCMS template is based on Django template engine syntax, which means you can control the display of content through simple tags. The template file for the article detail page is usually located in your theme directory underarchive/detail.html.
Operation Steps:
定位template file:
- Access your AnQiCMS installation directory through FTP or a file management tool.
- Enter
templateFolder, then find the name of the template theme you are currently using (for example,default). - Inside the template theme folder, find
archivethe folder in whichdetail.htmlthe file is the template for the article detail page. - Suggestion:Before modifying any template file, please make sure to backup the original file to prevent any operation errors.
Modify the title tag:Open
detail.htmlfile, you usually find in<head>similar within the tag<title>...</title>The structure. Here is where we need to make the modification.AnQiCMS provides
tdkTags to help you build titles. Below are several common custom title formats and their implementation methods:Only show the article title (SEO title takes priority):This is
tdkThe default behavior of tags, it will prioritize the 'SEO title' of the article, if not set, then use the title of the article itself.<title>{% tdk with name="Title" %}</title>This method can ensure that your page title is concise and clear, directly highlighting the theme of the article.
Article Title + Website Name:Many website titles are formatted as 'Article Title - Website Name'. This helps to enhance brand exposure.
<title>{% tdk with name="Title" siteName=true %}</title>siteName=trueThe parameters will telltdkThe label is automatically added after the article title, based on the website name configured in "Background Settings" -> "Global Settings".Article Title + Separator + Website Name:If you want to use a separator other than the default (default is
-),you can do so bysepParameter settings.<title>{% tdk with name="Title" siteName=true sep=" | " %}</title>Here the separator has been changed to
|.Article title + Parent category title + Website name:For articles with deep levels or classification information that is helpful for SEO, the title of the parent category can be displayed.
<title>{% tdk with name="Title" showParent=true siteName=true %}</title>showParent=trueThe title of the parent category will be displayed after the article title.More flexible custom combinations (using
archiveDetailandsystemLabel):IftdkThe options provided by tags may still not meet your very special title combination needs, you can directly callarchiveDetailTo get the details of the article,systemLabel fetches global information of the website and then manually assembles the title.For example, you may need to display the format such as 'Article Title - Website Name - Website Description'.
{% archiveDetail articleTitle with name="Title" %} {# 获取文章标题 #} {% system siteName with name="SiteName" %} {# 获取网站名称 #} {% tdk siteDescription with name="Description" %} {# 获取网站描述,这里我们借用tdk标签来获取description #} <title>{{ articleTitle | default:"" }} - {{ siteName | default:"" }} - {{ siteDescription | default:"" }}</title>- Here, we use
archiveDetailGet the article title (prefer SEO title, followed by actual title). systemTags are used to get the 'Website Name' from the global settings.tdkThe label here can be used to obtain the page description information.default:""filters (fromfilter-default.md)is used to prevent output when the variable is emptynilto make the page display cleaner.- Note: This manual concatenation method requires you to handle the priority of SEO titles and article titles, as well as the acquisition of category names (which can be obtained through
categoryDetailtags).
- Here, we use
Save and test:Save the changes made.
detail.htmlFile, and upload it to the server (if modified locally). Then visit the article details page of the website and check if the title in the browser tab is displayed as expected.
四、Operation Steps Summary
- Determine SEO Strategy:Define the format and information you want the article detail page title to follow.
- Using the 'SEO Title' field:For situations that require fine control over the title of a single article, fill in the 'SEO title' field when editing the article directly in the backend.
- Modify the template file:For titles that are globally or batch-effective, locate and edit.
template/{你的模板主题}/archive/detail.htmlfile. - Use
tdkTags:Based on the above examples, select or combine.tdkThe parameters of the tags to generate the title format you want. - (Optional) Manually combine:If
tdkThe label cannot be satisfied, then througharchiveDetail/categoryDetail/systemThe label manually get data and concatenate. - Save and test:Refresh the article detail page, check if the browser title meets the expectation.
5. Matters needing attention
- Template backup:Before modifying any template file, be sure to back it up.
- Clear cache: