Description: Used to obtain the title, keywords, and description information of the page
Usage:{% tdk 变量名称 with name="字段名称" %}
The variable name is not required. After setting the variable name, it can be called by the variable name later. If the variable name is not set, the result is output directly.
Parameters supported by tdk
- Whether to display the website name
siteName
siteName
Default ValuesiteName=false
only whenname="Title"
is effective.
The field names available for the name parameter are:
- Page Title
Title
- Page Keywords
Keywords
- Page Description
Description
- The specification link of the page
CanonicalUrl
Page TitleTitle
Tag Usage:{% tdk with name="Title" %}
Supports variables when "name=“Title”":
siteName
Property, can be set to whether to append the website name to the end of Title.siteName
For a bool type, it is not displayed by default. It is displayed using:){% tdk with name="Title" siteName=true %}
sep
property, you can set the separator, the default is-
showParent
Property, it can be set to determine whether the parent category title is displayed, the default isshowParent=false
only whenname="Title"
only takes effect when
{# 不显示网站名称后缀 #}
<title>{% tdk with name="Title" %}</title>
{# 显示网站名称后缀 #}
<title>{% tdk with name="Title" siteName=true %}</title>
{# 不显示网站名称后缀 #}
<title>{% tdk with name="Title" siteName=false %}</title>
{# 自定义名称调用 #}
<title>{% tdk seoTitle with name="Title" siteName=true %}{{seoTitle}}</title>
{# 自定义分隔符 #}
<title>{% tdk with name="Title" sep="_" %}</title>
{# 显示上级分类标题 #}
<title>{% tdk with name="Title" showParent=true %}</title>
Page KeywordsKeywords
Tag Usage:{% tdk with name="Keywords" %}
{# 默认用法 #}
<meta name="keywords" content="{% tdk with name="Keywords" %}">
{# 自定义名称调用 #}
<meta name="keywords" content="{% tdk seoKeywords with name="Keywords" %}{{seoKeywords}}">
Page DescriptionDescription
Tag Usage:{% tdk with name="Description" %}
{# 默认用法 #}
<meta name="description" content="{% tdk with name="Description" %}">
{# 自定义名称调用 #}
<meta name="description" content="{% tdk seoDescription with name="Description" %}{{seoDescription}}">
The specification link of the pageCanonicalUrl
Tag Usage:{% tdk with name="CanonicalUrl" %}
{# 默认用法 #}
<link rel="canonical" href="{% tdk with name="CanonicalUrl" %}" />
Generally speaking, it is necessary to first check if CanonicalUrl exists before setting it
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}