How to set the page title (Title) in AnQiCMS template and automatically append the website name?

Calendar 👁️ 84

In website operation, the page title (Title) is an extremely important element, as it not only directly affects the user's willingness to click in the search engine results page (SERP), but is also a key indicator 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 recognition 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. This 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, the system will intelligently select and combine the most appropriate titles based on the specific situation of the current page.

  1. Content-level SEO title:Whether it is an article, product detail page, or a standalone page, AnQiCMS provides the 'SEO Title' field. If you enter content here, it will be prioritized as the page's<title>Label content. This allows you to customize the independent title for each specific page to best fit the SEO strategy.
  2. The title of the content itself:If "SEO title" is not set, the system will use the actual title of the content by default, such as the article title, product name, or single page name.
  3. 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 a specific category list page.
  4. Website Global Title Setting:In the website backend's "Global Settings", you can find the "Website Name" field.This name is usually used as a website brand identifier, appended to 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 accurately control the display of page titles through the powerful template tags provided by AnQiCMS.

Core tags:tdkThe use of tags

AnQiCMS template usagetdkTag to retrieve the page's Title, Keywords, and Description information. We mainly focus on setting the page title and automatically attaching the site name.tdklabel'sname="Title"Parameter.

Here is the basic usage:

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

In the above code,{% tdk with name="Title" %}Will intelligently obtain the optimized title of the current page (based on the priority mentioned above).

Automatically attach the website name.

To make the page title automatically append the "Website Name" you configured in the "Global Settings" backend, you just need to intdkthe tag withsiteName=truethe parameter.

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

WhensiteName=trueWhen, the system will automatically add 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-to separate. If you want to use a different symbol, such as an underscore_or a vertical line|can be accessed throughsepSet the parameter:

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

This will display your page title as: "Article Title_Your Website Name".

Display parent category title

In some cases, especially for deeply nested category pages, you may want the title to include the name of the parent category to provide more complete context 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 the title in different page types

Considering the template file structure of AnQiCMS, you usuallybase.htmlin such a public template file<head>set the title in the regional area. BecauseextendsTags are the foundation of template inheritance, allowing you to define a global skeleton and override specific parts as needed in child templates.

For example, in yourbase.htmlthe file<head>The part can be set 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 this setting:

  • Home (index.html):The title will display as "The title you set in the TDK settings on the backend home page - Your website name".
  • Article/Product Details Page (archive/detail.html):The title will be displayed first according to the 'SEO title' of the article or product.If not set, then display the title of the article/product itself and add the website name.For example: “In-depth 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) and append the website name. IfshowParent=trueIt will also include the parent category name. For example: "Electronic Products Category - Your Website Name".
  • Single page (page/detail.html):The title will display as the 'SEO Title' (or page name) of a single page, along with the website name. For example: 'Contact Us - Your Website Name'.

In this way, you do not need to repeat the logic on each page template, justbase.htmlconfigure once, and you can achieve standardized and automated management of the entire site page titles.

Frequently Asked Questions (FAQ)

1. I modified the 'Website Name' in the background 'Global Settings', why hasn't the page title changed?

Make sure you are using it in the<title>tag correctlysiteName=truefor example:<title>{% tdk with name="Title" siteName=true %}</title>If this parameter is not provided, or the parameter isfalseThe system will not automatically append the website name. Additionally, after changing the background settings, it may be necessary to clear the website cache or refresh the page to see the latest effects.

2. Why are some page titles long while others are short 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 did not specify it intdkthe tags.siteName=trueOrsiteNameWithfalseIf the system will only display the custom "SEO title" without appending the website name. To ensure that the website name is appended to all pages, make sure yourbase.htmlin the filetdktag includessiteName=trueParameter.

3. How do I make certain pages not display the website name suffix?

If you only want a few specific pages not to display the website name suffix, you can use the overlay strategy. In the templates of these specific pages (for examplearchive/detail.htmlorpage/detail.html), you can redefine<title>Label, andsiteNamethe parameter tofalse:

{# 在特定页面的模板中,例如 archive/detail.html #}
{% extends 'base.html' %}

{% block title %}
    {# 覆盖 base.html 中的标题设置,不附加网站名称 #}
    <title>{% tdk with name="Title" siteName=false %}</title>
{% endblock %}

{# 其他内容块 ... #}

Or, directly enter the complete title, including or not including the website name, in the 'SEO Title' field, as it has the highest priority.

Related articles

How to customize the URL static rules of the article detail page in AnQiCMS?

In website operation, a clear and friendly URL structure is crucial for search engine optimization (SEO) and user experience.AnQiCMS provides flexible URL rewriting (URL rewrite) functionality, allowing users to customize the URL format of article detail pages according to their needs.This article will introduce in detail how to customize the URL static rules for the article detail page in AnQiCMS.Why do you need to customize URL static rules?

2025-11-08

How to display the publish time and update time of articles in AnQiCMS templates?

Understand the publication and update time of an article, which not only helps readers judge the timeliness of the content and avoid outdated information, but also is an important consideration for search engine optimization (SEO).AnQiCMS as an efficient content management system provides flexible template functions, allowing you to easily display these key time information on your website.

2025-11-08

How does AnQiCMS implement intelligent recommendation and display of related articles?

In content operation, effectively recommending relevant articles to readers can not only significantly increase user stay time and page views, but also indirectly promote search engines to crawl and allocate weights to the website's content through internal link optimization.AnQi CMS is well-versed in this, providing a smart and flexible mechanism to help users easily implement the recommendation and display of related articles.How does AnQiCMS implement intelligent article recommendation?

2025-11-08

How to display the links and titles of the previous and next articles on the article detail page?

When a reader visits an article of interest, they often hope to browse related or continuous content seamlessly, rather than returning to the list page to search again.Provide navigation links to "Previous" and "Next" articles on the article detail page of the website, which is an effective way to enhance this reading experience and increase user stickiness.It can not only guide users to explore the website content in depth, but also optimize the internal link structure of the website to a certain extent, making it friendly to search engines.AnQiCMS (AnQiCMS) is a powerful content management system that fully considers the needs of content operation

2025-11-08

How does AnQiCMS dynamically display the page keywords (Keywords) and description (Description)?

AnQiCMS has always been committed to providing flexible and powerful functions in content management and SEO optimization, with the dynamic display of page keywords (Keywords) and descriptions (Description) being one of its core highlights.For any website that hopes to perform well in search engines, precise TDK (Title, Description, Keywords) configuration is indispensable.

2025-11-08

How to implement the display of Canonical normative links in AnQiCMS templates to optimize SEO?

In the field of website operation and Search Engine Optimization (SEO), Canonical (standard) links are a very important concept.It can help search engines identify and handle duplicate content issues on websites, ensuring that the authority and ranking of the website are not affected by scattered content.In AnQiCMS (AnQi CMS), implementing the display of canonical links is a key step in optimizing website SEO, and through its flexible template system, this process becomes intuitive and efficient.

2025-11-08

What URL static mode does AnQiCMS support to optimize search engine crawling?

In today's internet world, an excellent website not only needs to provide high-quality content, but also needs to make it easy for users and search engines to discover this content.The importance of the structure of the URL (website address) is self-evident.A clean, meaningful URL not only improves user experience, but is also a key factor in search engine optimization (SEO).AnQiCMS (AnQiCMS) knows this and therefore took full consideration of the flexibility of pseudo-static URLs from the beginning, aiming to help users build websites friendly to search engines.Why is URL rewriting so important for SEO

2025-11-08

How to implement image lazy loading (Lazy Load) in AnQiCMS article content?

When building and operating a website, page loading speed is always a key factor in user experience and search engine optimization.Images are an important part of website content and are often one of the main reasons affecting loading speed.Implementing image lazy loading (Lazy Load) can significantly improve website performance, reduce unnecessary bandwidth consumption, and allow users to see page content faster.AnQiCMS as a powerful content management system, provides many conveniences for content operation.

2025-11-08