TDK Tags

Description: Used to obtain the title, keywords, description information of the page

How to use:{% tdk 变量名称 with name="字段名称" %}, the variable name is not necessary. After setting the variable name, you can call it through the variable name in the future. Without setting the variable name, the result will be output directly.

Parameters supported by tdk

  • Whether to display the website namesiteName
    siteNamedefault valuesiteName=false, only inname="Title"effective when it is.

The field names available for the name parameter are:

  • Page titleTitle
  • Page keywordsKeywords
  • Page DescriptionDescription
  • Page's specification linkCanonicalUrl

Page titleTitle

Tag usage:{% tdk with name="Title" %}name="Title" time variables support:

  • siteNameProperties, you can set whether to attach the website name to the Title.siteNameIt is a bool type and will not be displayed by default. Use when displaying:{% tdk with name="Title" siteName=true %}
  • sepAttributes, you can set the separator, the default is-
  • showParentAttribute, you can set whether to display the title of the parent category, the default isshowParent=false, only inname="Title"Only effective will take effect when it is .
{# 不显示网站名称后缀 #}
<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}}">

Page's specification linkCanonicalUrl

Tag usage:{% tdk with name="CanonicalUrl" %}

{# 默认用法 #}
<link rel="canonical" href="{% tdk with name="CanonicalUrl" %}" />

Generally speaking, CanonicalUrl needs to be determined first, and if so, then set it

{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}