How to concatenate the article title (Title) with the system-defined website name (SiteName) through the `tdk` filter and output to`Tag?\u003ch1\u003e
\u003cdiv class="meta"\u003e\n \n \u003cspan\u003e\u003ca href="https://en.anqicms.com/blog"\u003eAnQi BLOG\u003c/a\u003e\u003c/span\u003e\n \u003cspan\u003e2025-11-08\u003c/span\u003e\n \u003cspan\u003e49 Reads\u003c/span\u003e\n \u003c/div\u003e\n \u003cdiv class="article-body"\u003e\n \n \n \n \n \u003cp\u003eIn website operation,\u003ccode\u003e\u003ctitle\u003e\u003c/code\u003eTag is of great importance, not only is it the key for search engines to understand the theme of the page, but also the content that users see first in the search results.A well-crafted page title that can effectively increase click-through rate and have a positive impact on SEO optimization.Therefore, how to organically integrate the core title of the article with the brand name of the website into a <code><title></code> tag, which is a fundamental and important link in the design of the website template.</p>
<p>AnQiCMS is a feature-rich enterprise-level content management system that provides great flexibility in template design. Its template engine uses a syntax structure similar to Django.This means that you can output dynamic content by using double curly braces<code>{{ variable }}</code> and call various built-in functions and logical controls by using single curly braces and percent signs<code>{% tag %}</code>.This design makes it relatively easy for even non-professional developers to understand and modify the template.To implement the merging of the article title with the website name in the AnQiCMS template and output it to the <code><title></code> tag, we need to use several core features provided by the AnQiCMS template: get article details, get system settings, and a universal <code>tdk</code> filter specifically used for processing page SEO meta information.</p>
<p>First, the article title is the core content identifier of the page.When you visit a specific article detail page, AnQiCMS will automatically identify the article data on the current page.You can use the <code>archiveDetail</code> tag to get various properties of the article, including the title (<code>Title</code>).</p>
<p>Next, the website name (code: SiteName) is the unified name of the website you configure in the By using the <code>system</code> tag, you can easily access this global setting in the template, including the <code>SiteName</code>.</p>
<p>While the key to combining these two and outputting to the <code><title></code> tag is the <code>tdk</code> filter provided by AnQiCMS.This filter is specifically designed to handle page <code>title</code>, <code>keywords</code>, and <code>description</code>, and other SEO meta-information.It is very intelligent and can automatically fetch the most relevant content based on the type of the current page (such as article detail page, category list page, or homepage).<p>
To concatenate the article title and the website name using the <code>tdk</code> filter, you need to use the syntax <code>{% tdk with name="Title" siteName=true %}</code> inside the <code><title></code> tag.Here: <p></p>
<ul>
<li><code name="Title">: Indicates the <code tdk>filter to get the title information of the current page.</code></li>On the article detail page, it tries to get the article's <code>Title</code> field.<li>
<li><code>siteName=true</code>:This is a very convenient parameter, it tells the <code>tdk</code> filter to automatically add the system-set website name (<code>SiteName</code>) to the page title obtained.<li>
<li><code>sep=" - "</code>:You can also customize the separator between the title and the website name using the <code>sep</code> parameter, for example <code>" - "</code>、<code>" | "</code> or <code>" _ "</code> etc., the default is usually <code>-</code> or <code>_</code>.It is very important to choose a delimiter that is both aesthetically pleasing and SEO-friendly.<li></li>
</ul>
<p>Place the above code in the <code><head></head></code> section of the template file, a typical article detail page's <code><title></code> tag will be like this:</p>
<pre><code class="language-html">!</code>DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Core Title Tag, automatically concatenate article title and site name -->
<title>{% tdk with name="Title" siteName=true sep=" - " %}</title>
<!-- Also, you can get the page keywords and description -->
<meta name="keywords" content="{% tdk with name="Keywords" %}" >
<meta name="description" content="{% tdk with name="Description" %}" >
{# Here you can place other head content, such as CSS links, Favicon, etc. #}
</head>
<body>
{# Website main content #}
</body>
</html>
</code></pre>
<p>When your website visitor is browsing an article named "AnQiCMS: The Secret Weapon of Efficient Content Management" if your website name is set to "AnQiCMS Official Website", then the final title displayed in the browser tab will be: "AnQiCMS: The Secret Weapon of Efficient Content Management - AnQiCMS Official Website".<p></p>
<p>It is worth mentioning that in the AnQiCMS article editing interface, you will usually find a field called "SEO Title (SeoTitle)".This field allows you to set a special title for the article that is used for search engine display, which will take precedence over the article's own <code>Title</code> field when the <code>tdk</code> filter retrieves the title.This means that if you set a "SEO title" for the article, then the <code>tdk</code> filter will use that "SEO title" concatenated with the website name instead of the article's regular title.This provides you with more fine-grained SEO control capabilities, ensuring that each page has the most suitable title for search optimization.</p>
<p>Generally, to maintain consistency across the entire site, the settings of this <code>title</code> tag are placed in the common header file of the website (such as <code>base.html</code> or <code>header.html</code>), so that all pages can automatically inherit and generate standard titles.In this way, you do not need to write the <code><title></code> tag separately for each page, AnQiCMS will automatically handle it for you, greatly improving the efficiency of website management and SEO optimization.</p>
<hr>
<h3>Common Questions (FAQ)</h3>
<p><strong>1. Why did I set <code>siteName=true</code>, but the website name did not display in the <code>title</code> tag?This is usually because you have not filled in the "SiteName" field in the "Global Function Settings" of the AnQiCMS backend, or the field is left blank.Please check the backend settings to ensure that the 'Website Name' field has clear content.The <code>tdk</code> filter will read this information from the system settings, and it will not concatenate if it cannot be read.<p>
<p><strong>2. I want the <code>title</code> tag on some pages to only display the article title and not concatenate the website name, how can I do this??< /strong> < /p>
< p> You can set the < code>tdk< /code> filter's < code>siteName< /code> parameter to < code> false< /code> in a separate display page template, or simply omit the parameter (because the < code>siteName< /code> default value is < code> false< /code>).For example, you can write: <code><title>{% tdk with name="Title" siteName=false %}</title></code> or simply <code><title>{% tdk with name="Title" %}</title></code>.This will make AnQiCMS only output the title of the current page without adding the website name.</p>
<p><strong>3. What is the use of the 'SEO Title' field in the article??What is the difference between it and the normal "title" of the article?</strong></p><br><p>The "SEO title" (SeoTitle) field allows you to set an independent, optimized title for search engines, which will take precedence over the normal title you enter in the "Article title" (Title) field when the <code>tdk</code> filter generates the <code><title></code> tag.In other words, if you have set the 'SEO Title', the <code><title></code> tag will use the 'SEO Title';If you do not set it, the default will be used as 'Article Title'.This design aims to provide you with greater flexibility, you can use a common "title" to attract readers, and use the "SEO title" to meet the optimization needs of search engines.</p>
</div>
</div>
</div>
</div>
<div class="layui-card">
<div class="layui-card-body">
<div class="article-prev-next">
<li>
Previous:
<a href="https://en.anqicms.com/blog/9421.html">`dump` filter in Anqicms template debugging: some practices, how to clearly view the structure and value of complex variables?</a>
<li>
<li>
Next:
<a href="https://en.anqicms.com/blog/9423.html">`tdk` filter how to configure delimiter (`sep`) and whether to display parent category title (`showParent`) in Anqicms?<a></a>\n \n \n <li></li>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n <div class=\</h5>\n </a>\n </li>\n \n \n <li class=\</h5>
</a>
</li>
</li class="item">
<a href="https://en.anqicms.com/blog/10496.html" class="link">
<h5 class="title">Does the AnQiCMS document list interface support more complex queries of the `extra` field in the returned data?</h5>
</a>
</li>
</li class="item">
<a href="https://en.anqicms.com/blog/10495.html" class="link">
<h5 class="title">How to use the `archive/list` interface to dynamically load more documents on the front end (infinite scrolling)?</h5>
<a href="https://en.anqicms.com/blog/10494.html" class="link">
<h5 class="title">The `archive/list` interface returns the `canonical_url` and `fixed_link` fields, what is the help to SEO optimization? </h5>
</a>
</li>
<li class="item">
</li>
<li class="item">
</li></h5>
</a>
</li>
</li class="item">
<a href="https://en.anqicms.com/blog/10493.html" class="link">
<h5 class="title">What will `data` and `total` return if no documents meeting the criteria are found in the AnQiCMS document list??</h5> </a> </li>
</ul>
</div> </div> <div class="layui-card"> <div class="layui-card-header">相关文章</div> <div class="layui-card-body">
</ul>
<li class="item"> <a href="https://en.anqicms.com/blog/9421.html" class="link"> <h5 class="title">`dump` filter in AnqiCMS template debugging: what practices are there, and how can complex variable structures and values be clearly viewed?</h5> </a> </li>
<li class="item"> <a href="https://en.anqicms.com/blog/9420.html" class="link"> <h5 class="title">How to safely output the HTML code passed from the backend through the `safe` filter in Anqi CMS template to avoid escaping? </a> </li> </h5>
</a>
</li>
<li class="item">
<a href="https://en.anqicms.com/blog/9419.html" class="link">
<h5 class="title">`urlize` and `urlizetrunc` filters in Anqicms, how to automatically identify URLs and email addresses in text and convert them into clickable links?</h5>
<a href="https://en.anqicms.com/blog/9423.html" class="link">
<h5 class="title">`tdk` filter how to configure separator (`sep`) and whether to display parent category title (`showParent`) in Anqicms?</h5>
</a>
</li>
<li class="item">
<a href="https://en.anqicms.com/blog/9424.html" class="link">
<h5 class="title">How to use the `stringformat` filter in AnqiCMS template to format price numbers as currency (e.g., “¥%.2f”)?</h5>
</a>
</li>
</li>
<li class="item">
<a href="https://en.anqicms.com/blog/9425.html" class="link">
<h5 class="title">`stringformat` filter in Anqicms how to handle null or invalid input, will it return an error or a default value??</h5>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="footer-block">
<footer class="layui-footer">
<div class="layui-container">
<div class="layui-row layui-col-space30" style="margin-left: -8px;"> margin-right: -8px; row-gap: 16px;">
<div class="layui-col-lg4 footer-block">
<h3>Anqi Content Management System(AnqiCMS)</h3>
<p><img src="/anqicms.png" style="width: 96px;">" /></p>
<p>AnqiCMS Content Management System, an enterprise-level content management system developed using GoLang, is easy to deploy, secure, with a graceful interface, compact, and fast execution speed. Websites built with AnqiCMS can prevent many security issues.<p>\n </p>\n </div>\n <div class=\
al.src = "/api/log?action=views&code=200&id=9422&path=http%3A%2F%2Fwww.anqicms.com%2Fblog%2F9422.html&type=archive&nonce=%2BDate.now();
document.body.appendChild(al);
})();
</script>
<script src="https://en.anqicms.com/static/anqitpl1/js/template.js?v=1.3"\u003e\u003c/script\u003e\n\u003cscript src="https://en.anqicms.com/static/anqitpl1/layui/layui.js"\u003e\u003c/script\u003e\n\u003cscript type="module"\u003e\n import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
<script>
layui.config({
base: "https://en.anqicms.com/static/anqitpl1/js/"
}).use(['index','pjax']); //Loading entry
</script>
<script src="https://en.anqicms.com/static/anqitpl1/js/app.js?v=1.5.7"></script>
<div class="layui-hide"><script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?23ac1576d1ee72920a3d65a2cf536ac0";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);))());
</script>
</div>
</html>