In website operation, the title of the article detail page (<title>Tags are crucial for search engine optimization (SEO).A well-designed title can not only improve the click-through rate of the article in the search results, but also help search engines better understand the page content.AnQiCMS provides a flexible mechanism that allows you to easily customize the title display format of the article detail page according to your own SEO strategy.

This article will introduce how to adjust the title of the article detail page in AnQiCMS to meet different SEO requirements.

One, understand the title structure of AnQiCMS

In AnQiCMS, the title of the article detail page usually consists of several parts, such as the article title, the category name it belongs to, and the website name, etc. By default, AnQiCMS will automatically generate according to the content you fill in when you publish the article and the global system settings.<title>.

AnQiCMS provides a universal tag for controlling page title, keywords, and descriptions (TDK)tdkThis tag is the core tool for custom title display format.In addition, 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 'Other Parameters' collapse box.Operation method:

  1. Log in to the AnQiCMS backend.
  2. Go to 'Content Management' -> 'Document Management'.
  3. Click "Add new document" or edit an existing document.
  4. On the document editing page, find the "Other parameters" section and expand it.
  5. In the 'SEO Title' field, enter the title you want to display on the article detail page<title>The full title in the tag.

Effect:If you fill in content here, AnQiCMS will prioritize using this field as the title of the article detail page, and ignore the default article title.This is very suitable for the scenario where it is necessary to write highly optimized SEO titles for specific articles that may be slightly different from the actual title of the article.

3. Adjust the TDK tag 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 files for article detail pages are usually located in the template theme directory of yourarchive/detail.html.

Operation steps:

  1. Locate the template file:

    • Access your AnQiCMS installation directory via FTP or a file management tool.
    • EntertemplateThen find the template theme name you are currently using (for exampledefault)
    • In the template theme folder, findarchivefolder, in whichdetail.htmlthe file is the template for the article detail page.
    • Suggestion:Before modifying any template file, please make sure to back up the original file to prevent any operation errors.
  2. Modify the title tag:Open.detail.htmlFile, you usually will find in<head>Find similar within the tag<title>...</title>The structure. This is where we need to modify.

    AnQiCMS providedtdkTags to help you build titles. Here are several common custom title formats and their implementation methods:

    • Only display the article title (SEO title preferred):This istdkThe default behavior of tags, it will prioritize the use of the article's 'SEO title', if not set, then use the article's own title.

      <title>{% tdk with name="Title" %}</title>
      

      This way can ensure that your page title is concise and clear, directly highlighting the article theme.

    • Article title + Website name:The title format of many websites is "Article Title - Website Name". This helps to enhance brand exposure.

      <title>{% tdk with name="Title" siteName=true %}</title>
      

      siteName=trueThe parameters will telltdkThe tag is automatically added after the article title, as configured in the "Background Settings" -> "Global Settings" of the "Website Name".

    • Article Title + Separator + Website Name:If you want to use a separator other than the default (which is-), you cansepSet the parameters.

      <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 deeper levels or category information helpful for SEO, the parent category title can be displayed.

      <title>{% tdk with name="Title" showParent=true siteName=true %}</title>
      

      showParent=trueThe parent category title will be displayed after the article title.

    • More flexible custom combinations (usingarchiveDetailandsystemTag):IftdkThe options provided by the tags still cannot meet your very special title combination needs, you can callarchiveDetailTags to get article details, as well assystemThe tag retrieves the global information of the website and then manually assembles the title.

      For example, you may need to display the format: "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>
      
      • This has been usedarchiveDetailGet the article title (prefer SEO title, followed by actual title).
      • systemTags are used to retrieve the "website name" from global settings.
      • tdkThis label can be used to obtain the description of the page.
      • default:""Filter (fromfilter-default.md) is used to prevent output when the variable is emptynil, making 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 achieved throughcategoryDetailtags).
  3. Save and test:Save the modifieddetail.htmlFile, and upload it to the server (if you are modifying it locally). Then visit the article detail page of the website and check if the browser tab title is displayed as expected.

Four, Summary of Operation Steps

  1. Determine the SEO strategy:Clarify the format and information you want the article detail page title to follow.
  2. Use the "SEO Title" field:For cases that require fine control of a single article's title, fill in the "SEO Title" field directly when editing the article in the background.
  3. Modify the template file:For title formats that apply globally or in bulk, locate and edit.template/{你的模板主题}/archive/detail.htmlfile.
  4. UsetdkTags:Select or combine based on the above exampletdkUse the parameters of the tag to generate the title format you want
  5. (Optional) Manually combine:IftdkIf the tag does not meet the requirements, proceed througharchiveDetail/categoryDetail/systemWait and manually retrieve the data and concatenate the tags.
  6. Save and test:Refresh the article detail page and check if the browser title meets the expectation.

5. Notes

  • Template backup:Before modifying any template file, be sure to make a backup.
  • Clear the cache: