In website operation, the page title (Title) is an extremely important element. It not only directly affects the willingness of users to click on search engine results pages (SERP), but is also one of the key indicators for search engines to judge the relevance of page content.A clear, standardized title that includes the website brand name, which can effectively enhance the professionalism and brand awareness of the website.
AnQiCMS provides a flexible and powerful mechanism for setting website titles, allowing you to easily control the title of each page and automatically append the website name, which is very beneficial for maintaining brand consistency and optimizing search engine visibility.
Understand the page title hierarchy in AnQiCMS
In AnQiCMS, the generation of page titles follows certain priority rules.This means you can set titles at different levels, and the system will intelligently select and combine the most suitable title based on the specific situation of the current page.
- SEO title at the content level:Whether it is an article, product detail page, or a single page, AnQiCMS provides the 'SEO Title' field. If you fill in content here, it will take priority as the page's
<title>Tag content. This allows you to customize the independent title that best fits the SEO strategy for each specific page. - The title of the content itself:If 'SEO Title' is not set, the system will default to using the actual title of the content, such as the article title, product name, or single page name.
- Category Level SEO Title:For category pages, you can set the 'SEO Title' in the category management. This allows you to define a unique title for specific category list pages.
- Website Global Title Setting:In the "Global SettingsThis name is usually used as a website brand identifier, appended to the end of the page title.The TDK (Title, Description, Keywords) of the homepage can also be independently configured in the "Homepage TDK Settings".
After understanding these levels, we can precisely control the display method of the page title through the powerful template tags provided by AnQiCMS.
Core tags:tdkUse of tags
AnQiCMS template usagetdkGet the page Title, Keywords, and Description information by tagging. To set the page title and automatically attach the site name, we mainly focus ontdkTagsname="Title"Parameter.
The basic usage is as follows:
<title>{% tdk with name="Title" %}</title>
In the above code,{% tdk with name="Title" %}It will intelligently obtain the most optimized title of the current page (based on the priority mentioned above).
Automatically attaches the website name
To make the page title automatically append the 'Website Name' you configured in the background 'Global Settings', you just need to in thetdktag.siteName=trueparameter.
<title>{% tdk with name="Title" siteName=true %}</title>
WhensiteName=trueWhen this occurs, the system will automatically append the website name to the end of the current page title, for example: 'Article Title - Your Website Name'.
Custom title separator
By default, the page title and website name are separated by a hyphen-Use other symbols, such as underscores_or vertical line|, you cansepset the parameter to:
<title>{% tdk with name="Title" siteName=true sep="_" %}</title>
So, your page title will display as: "Article Title_Your Website Name".
Display parent category title
In some cases, especially for deeper category pages, you may want the title to include the names of its parent categories to provide more complete contextual information. At this time, you can useshowParent=trueParameters:
<title>{% tdk with name="Title" siteName=true showParent=true %}</title>
For example, if your category structure is 'Product > Electronic Products > Phone', when you visit the 'Phone' category page, the title may display as: 'Phone - Electronic Products - Your website name'.
Set titles in different page types
Considering the template file structure of AnQiCMS, you usually willbase.htmlsuch public template files<head>set the title in the region. BecauseextendsTags are the foundation of template inheritance, allowing you to define a global skeleton and overlay specific parts as needed in child templates.
For example, in yourbase.htmlthe file<head>section, you can set it up like this:
<!DOCTYPE html>
<html lang="{% system with name='Language' %}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% tdk with name="Title" siteName=true sep=" - " showParent=true %}</title>
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}
<!-- 其他头部信息 -->
<link rel="stylesheet" href="{% system with name="TemplateUrl" %}/css/style.css">
</head>
<body>
<!-- 网站内容 -->
</body>
</html>
After setting like this:
- Home Page (
index.html):The title will display as “The title you set in the backend home page TDK settings - Your website name”. - Article/Product Detail Page (
archive/detail.html):The title will be displayed first based on the article/product's 'SEO Title'.If not set, it will display the title of the article/product itself and append the website name.For example: "Deep analysis of AnQiCMS template creation - Your website name". - Category list page (
category/list.html):The title will display as the "SEO Title" (or category name) of the category and will be appended with the site name.showParent=trueIt will also include the parent category name. For example: "Electronics Category - Your Website Name". - Single Page (
page/detail.html):The title will display as the 'SEO Title' (or page name) of a single page, and appended with the website name. For example: 'Contact Us - Your Website Name'.
By this means, you do not need to repeat the logic on each page template, just inbase.htmla single configuration, you can achieve standardized and automated management of the site's page titles.
Common Questions (FAQ)
1. I have modified the 'Website Name' in the 'Global Settings' on the backend, why hasn't the page title changed?
Make sure you are using the template correctly in the<title>tags correctly used in thesiteName=trueParameter, for example: <title>{% tdk with name="Title" siteName=true %}</title>If this parameter is not specified or the parameter isfalseThe system will not automatically append the website name. Moreover, after changing the background settings, it may be necessary to clear the website cache or refresh the page to see the latest effects.
Why are some page titles long, while others are only a few words and do not include the website name?
This usually has to do with the priority of the title. If a page (such as an article, category, or single page) has set the "SEO title" during editing, and you intdkThere is no explicit specification in the tagssiteName=true, orsiteNameresponse forfalseIf so, the system will only display the custom "SEO title" without adding the site name. To ensure that the site name is added to all pages, please make sure yourbase.htmlin the filetdktag includessiteName=trueParameter.
I want to make certain specific pages not display the website name suffix. How should I do that?
If you only want to hide the website name suffix on a few specific pages, you can use the override strategy. In the templates of these specific pages (for examplearchive/detail.htmlorpage/detail.html), you can redefine<title>tags, andsiteNameparameter settingsfalse:
{# 在特定页面的模板中,例如 archive/detail.html #}
{% extends 'base.html' %}
{% block title %}
{# 覆盖 base.html 中的标题设置,不附加网站名称 #}
<title>{% tdk with name="Title" siteName=false %}</title>
{% endblock %}
{# 其他内容块 ... #}
Or, directly enter the full title, including or not including the website name, in the 'SEO Title' field, as it has the highest priority.