In content operation, setting the title of the article detail page on the website is a key link. We often encounter such situations: the content title of the article itself needs to be eye-catching and creative to attract readers' clicks; while the page title required for search engine optimization (SEO) (i.e., the title displayed on the browser tab)<title>Label content), then it is more focused on the layout, length control of keywords, and friendliness to search engines.In AnQiCMS, you can fully flexibly manage these two different titles, ensuring both user experience and SEO effect.
How to implement custom SEO title in AnQiCMS
AnQiCMS fully considers the needs of SEO optimization, and provides an independent "SEO title" field for each article.This means you can set a separate article title for display to readers and an SEO title for search engine inclusion and display.
When you edit or publish articles, just pay attention to the collapsed area of "Other Parameters" at the bottom of the page.Expand this area, and you will see an input box named "SEO Title".This field is where AnQiCMS customizes the SEO title setting for your article detail page.<title>The content of the tag, while the "Document Title" you set at the top of the article will be as the page content<h1>Title, for users to read.
Call custom SEO title in template
To correctly display this custom SEO title in the article detail page's HTML header, we need to use the powerful template tags provided by AnQiCMS in the template file. Usually, the template file for the article detail page would be{模型table}/detail.htmlor you have specified a custom template for this article in the background.
AnQiCMS provides a namedtdktags, used specifically for managing the page in a unified manner.title/descriptionandkeywordsthese core SEO elements. Usetdktag to call the SEO title is very intuitive:
<title>{% tdk with name="Title" %}</title>
This code will intelligently retrieve the SEO title of the current article.If you enter content in the 'SEO title' field of the article, it will display your custom SEO title by default; if no content is entered, the system will fallback to using the 'document title' of the article itself, or other preset TDK logic, to ensure that the page always has a valid title.
Furthermore,tdkTags also provide flexible parameters, allowing you to better control the display of the title. For example, automatically adding your website name at the end of the SEO title is very helpful for brand exposure and recognition:
<title>{% tdk with name="Title" siteName=true %}</title>
tositeNameparameter settingstrueYour page title will automatically be appended with the website name after the SEO title, usually followed by a hyphen-Separator (default separator). If you wish to change the separator, you can usesepParameters:
<title>{% tdk with name="Title" siteName=true sep="_" %}</title>
so, your SEO title and website name will be separated by an underscore_Establish connection.
in addition to the SEO title, we strongly recommend that you also usetdkTags inheadArea introduction article keywords and descriptions, this information can also be set in the "Other Parameters" on the article editing page:
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">
Complete example
Integrate the above template code snippet into your article detail pageHTMLof<head>Part, a typical article detail page header structure may look like the following:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
{# 使用tdk标签动态生成SEO标题,并自动带上网站名称,以短横线分隔 #}
<title>{% tdk with name="Title" siteName=true sep=" - " %}</title>
{# 使用tdk标签动态生成页面关键词 #}
<meta name="keywords" content="{% tdk with name="Keywords" %}">
{# 使用tdk标签动态生成页面描述 #}
<meta name="description" content="{% tdk with name="Description" %}">
{# 引入CSS样式文件,这里使用的是系统提供的模板静态文件地址标签 #}
<link rel="stylesheet" href="{% system with name="TemplateUrl" %}/css/style.css">
{# 可以在此处添加其他SEO优化标签,如canonical链接等 #}
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}
{# 网站的实际文章标题,通常作为页面内容的核心H1标签 #}
</head>
<body>
<article>
<h1>{% archiveDetail with name="Title" %}</h1> {# 这里的Title是文章的原始标题,用于内容展示 #}
{# 接下来是文章正文内容,可以使用 archiveDetail 的 Content 字段 #}
<div>
{% archiveDetail articleContent with name="Content" %}
{{ articleContent|safe }}
</div>
{# 其他文章详情元素,如发布时间、作者等 #}
</article>
{# 页面底部内容 #}
</body>
</html>
Through the above configuration, your CMS article detail page will be able to achieve search engine friendly custom SEO titles while maintaining the readability attractiveness of the article title itself, bringing better effects to your content operation.
Common Questions and Answers (FAQ)
Why is my article detail page
<title>Why does the tag still show the article title instead of the SEO title?This is usually caused by two reasons: one, you may have forgotten to fill in the 'SEO Title' field in the 'Other Parameters' section of the article editing page; two, your template file (usually{模型table}/detail.htmlor a custom template) is not used correctly{% tdk with name="Title" %}tags to call the SEO title. Please check these two places to make sure that the SEO title is set and the template call method is correct.Is there a character limit for custom SEO titles?AnQiCMS system itself has no rigid limit on the number of characters in SEO titles, but in order to ensure the display effect and user experience of the search engines, we strongly recommend that you control the SEO title within60-70 characters (about 30-35 Chinese characters)within. Long titles may be truncated on the search results page, affecting the delivery of complete information.
Can custom SEO titles also be set for categories and single pages in addition to articles?Yes, AnQiCMS also supports setting custom SEO titles for categories and single pages. When editing a category or a single page, you will find similar 'other parameters' or direct 'SEO title' fields, where you can fill in the content, and then use it in the template of the corresponding category list page or single page detail page.
{% tdk with name="Title" %}Call the label to use it. This ensures that all key pages of your website's SEO titles can be finely managed.