As a website operator deeply involved in AnQiCMS, I am well aware of the importance of content in the digital age and how to attract and retain users through carefully crafted and optimized content.In SEO work, TDK (Title, Description, Keywords) is one of the most basic and most important optimization links of the website, and how to make it dynamic to adapt to the constantly changing content and market demand is the key to improving the website performance.

This article will discuss in detail how to use the powerful template tag system of AnQiCMS to achieve dynamic display of home page TDK, making your website home page more attractive and search engine friendly.

Understand the TDK basic management of AnQiCMS

Before delving into dynamic TDK, we first need to understand how AnQiCMS manages TDK.AnQiCMS provides an intuitive backend setting, allowing you to set TDK for various page types on the website (including the homepage, article detail page, category list page, etc).For the homepage, you can configure it through the "Backend Settings" -> "Homepage TDK Settings" module in the backend.Here, you can manually enter the title, keywords, and description for the homepage.This manual input TDK content constitutes the basis of the home page TDK.

The core of dynamic TDK:tdkTag

AnQiCMS template system adopts a syntax similar to the Django template engine, wheretdkTags are a key tool for obtaining page TDK information. They can automatically retrieve and output the corresponding TDK content based on the current page context.

tdkThe basic method of using the tag is{% tdk 变量名称 with name="字段名称" %}.nameSpecify the TDK field you want to retrieve, for exampleTitle(Title),Keywords(Keyword) orDescription(Description).

For example, in your home page 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 home page template, AnQiCMS will automatically extract the corresponding data from the content you have configured in the "Home Page TDK Settings" backend.

Implement the dynamic TDK strategy on the homepage

AlthoughtdkThe tag can obtain the basic TDK configured on the backend, but the true meaning of "dynamically displaying certain data" often refers to integrating some non-fixed, time-varying, or content-changing data that updates over time into the TDK.AnQiCMS template tags provide multiple ways to achieve this goal.

1. Dynamically attach the website name to the homepage title

The homepage title usually needs to include the brand name of the website, while AnQiCMS'stdkThe tag has built-in this dynamic feature. By setting upname="Title"oftdktagssiteName=trueProperty, the system will automatically append the website name you configured in the "Global Function Settings" dynamically to the title of the homepage. You can also usesepProperty custom separator.

"twig {# Assume the background "