TDK Tag

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 namesiteName siteNameDefault ValuesiteName=falseonly whenname="Title"is effective.

The field names available for the name parameter are:

  • Page TitleTitle
  • Page KeywordsKeywords
  • Page DescriptionDescription
  • The specification link of the pageCanonicalUrl

Page TitleTitle

Tag Usage:{% tdk with name="Title" %}Supports variables when "name=“Title”":

  • siteNameProperty, can be set to whether to append the website name to the end of Title.siteNameFor a bool type, it is not displayed by default. It is displayed using:){% tdk with name="Title" siteName=true %}
  • sepproperty, you can set the separator, the default is-
  • showParentProperty, it can be set to determine whether the parent category title is displayed, the default isshowParent=falseonly 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 %}