This article will discuss in detail how to use the powerful template tag system of AnQiCMS to dynamically display the TDK on the homepage, making your website homepage more attractive and search engine friendly.
Understand the basic TDK management of AnQiCMS
Before delving into dynamic TDK, we first need to understand how AnQiCMS manages TDK.AnQiCMS provides an intuitive backend setup, allowing you to set TDK for various page types on the website (including the homepage, article detail pages, category list pages, etc.).For the homepage, you can configure it through the "Background Settings" -> "Homepage TDK Settings" module in the backend.Here, you can manually input the title, keywords, and description for the homepage.These manually entered TDK content constitutes the foundation of the homepage TDK.
The core of dynamic TDK:tdktags
AnQiCMS's template system adopts syntax similar to the Django template engine, wheretdkTags are a key tool specifically used to obtain page TDK information. It can automatically retrieve and output the corresponding TDK content based on the current page context.
tdkThe basic usage of the tag is{% tdk 变量名称 with name="字段名称" %}. Among themnameThe parameter specifies the TDK field you want to obtain, for exampleTitle(Title),Keywords(Keywords) orDescription(Description).
For example, in your homepage template, you can use the following method to retrieve and output TDK:
<title>{% tdk with name="Title" %}</title>
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">
When these tags are placed in the homepage template, AnQiCMS will automatically extract the corresponding data from the content you configured in the "Homepage TDK Settings" on the backend to display.
Implement the dynamic TDK strategy on the homepage
Althoughtdk
1. Dynamically add the website name to the homepage title
The homepage title usually needs to include the brand name of the website, while for AnQiCMS'stdkThe label has built-in this dynamic feature. By addingname="Title"oftdkLabel addsiteName=trueProperty, the system will automatically append the website name you configured in the "Global Feature Settings" dynamically to the end of the homepage title. You can also usesepProperty custom delimiter.
`twig {# Assume the backend “