As an operator who deeply understands the operation of AnQiCMS, I know that content is the core position in website construction, and the high quality of content not only manifests in its depth and breadth, but also in whether it can be effectively discovered by target users and search engines.SEO (Search Engine Optimization) titles, keywords, and descriptions are the bridge of communication between content and search engines.It is crucial to correctly obtain and apply these SEO elements for single-page content in AnQiCMS.
UnderstandingpageDetailThe role of tags in single-page content management.
In AnQiCMS,pageDetailThe tag is specifically used to retrieve detailed information of a single page from the database.It allows template developers and operators to flexibly extract various properties of a single page based on the page ID or URL alias, thereby displaying or further processing it on the frontend.pageDetailTags are tools to obtain the core content.
pageDetailThe basic usage of tags is for{% pageDetail 变量名称 with name="字段名称" id="1" %}. Among them,变量名称is an optional parameter, if specified, can assign the obtained field value to a variable for easy multiple references in the template; if not specified, the field value will be output directly.
This tag supports the following main parameters to specify which single page to retrieve:
id: Retrieve the details of the single page by specifying its ID. This is the most direct way to specify.token: Access the details through a single-page URL alias (also known as a custom URL). This is very useful when the URL structure is clear.siteIdIn a multi-site management environment, if you need to obtain single-page data from a non-current site, you can specify the site ID through this parameter. Usually, this parameter does not need to be filled in.
Get the title and description of a single page content
When we talk about the title and description of a single page, the first thing that comes to mind is the "content title" and "content description" as part of its core content components. AnQiCMS allows you topageDetailLabel directly retrieve these fields:
Get the title of a single page (Title)
Each single page has a main title, which is a brief summary of its content. You can get it by usingnamethe parameter to"Title"to get it.
{# 默认用法,自动获取当前页面单页的标题 #}
<div>单页标题:{% pageDetail with name="Title" %}</div>
{# 获取指定ID单页的标题 #}
<div>指定ID单页标题:{% pageDetail with name="Title" id="10" %}</div>
{# 将标题值赋给变量后使用 #}
{% pageDetail pageMainTitle with name="Title" %}
<div>当前页面主标题:{{ pageMainTitle }}</div>
Get the description of a single page (Description)
The content description of a single page is a summary of the page theme or content, usually used to introduce content in the main part of the page. UsepageDetailtags and setnameparameters for"Description"to get it.
{# 默认用法,自动获取当前页面单页的描述 #}
<div>单页描述:{% pageDetail with name="Description" %}</div>
{# 获取指定ID单页的描述 #}
<div>指定ID单页描述:{% pageDetail with name="Description" id="10" %}</div>
{# 将描述值赋给变量后使用 #}
{% pageDetail pageSummary with name="Description" %}
<div>当前页面摘要:{{ pageSummary }}</div>
Please note, the information obtained hereTitleandDescriptionMainly refers to the 'Page Name' and 'Page Summary' filled in when editing the single page in the background. They constitute the basic content information of the page.
Get the SEO title, keywords, and description of a single page
For content operators, it is not enough to simply obtain the content title and description of the page, we are more concerned with those SEO metadata that directly affect the search engine ranking, namely the page's<title>Tag content,<meta name="keywords">and<meta name="description">.
In AnQiCMS, although the background provides independent 'SEO title' and 'keywords' configuration options for single pages, butpageDetailThe design of the label itself focuses on obtaining the page.Content field. To provide a unified and dynamic SEO metadata retrieval mechanism, AnQiCMS introduces a more general tag: tdkLabel.This 'Universal TDK tag' can automatically extract and provide the most accurate SEO metadata based on the context of the current page (whether it is a single page, article detail page, or category list page).
Therefore, to obtain the SEO title, keywords, and description of a single page, we should prioritize usingtdk.
To get the page SEO title (Title)
tdkTagging for obtainingTitleSpecifically used for pages<title>Label.It will prioritize using the "SEO title
{# 最基础的SEO标题,不包含网站名称 #}
<title>{% tdk with name="Title" %}</title>
{# 包含网站名称作为后缀的SEO标题,使用默认分隔符 "-" #}
<title>{% tdk with name="Title" siteName=true %}</title>
{# 包含网站名称作为后缀,并自定义分隔符 "_" #}
<title>{% tdk with name="Title" siteName=true sep="_" %}</title>
{# 将SEO标题赋给变量后使用 #}
{% tdk seoPageTitle with name="Title" siteName=true %}
<title>{{ seoPageTitle }}</title>
Retrieve the page's SEO keywords (Keywords)
tdkTags can retrieve the SEO keywords specifically set for single-page by the backend, used to fill in the page's<meta name="keywords">.
{# 获取页面的SEO关键词 #}
<meta name="keywords" content="{% tdk with name="Keywords" %}">
{# 将SEO关键词赋给变量后使用 #}
{% tdk seoPageKeywords with name="Keywords" %}
<meta name="keywords" content="{{ seoPageKeywords }}">
Retrieve the page's SEO description (Description)
tdkThe tag can also retrieve the SEO description set for the single page on the backend, used to fill in the page.<meta name="description">Tag. It will use the SEO description configured in the background first, and if not configured, it may fall back to the page's "single-page introduction."
{# 获取页面的SEO描述 #}
<meta name="description" content="{% tdk with name="Description" %}">
{# 将SEO描述赋给变量后使用 #}
{% tdk seoPageDescription with name="Description" %}
<meta name="description" content="{{ seoPageDescription }}">
pageDetailwithtdkCollaboration and **Practice of Tag
As a content operation personnel, understandpageDetailandtdkThe focus of each tag is the key to efficiently optimizing website optimization.
pageDetailTags are the tools you use to obtain single-pagemain content fieldsuch as, in