Wagtail:从推广选项卡获取数据?
Wagtail: Get data from promote tab?
创建新页面时,有一个“推广”选项卡。在“搜索引擎”部分下有一个“标题标签”和一个“元描述”值。据我了解,“标题标签”设置文档的标题,“元描述”设置文档的元描述。但是我如何在我的页面模板中实际使用这些值?
我进行了广泛的搜索,但似乎 Wagtail 的文档没有解释任何关于“推广”选项卡或其用途的内容。那里定义的值是否可用作模板变量?我将如何实际访问页面的“标题标签”或“元描述”?
这些字段是 documented very briefly here。它们只是基础 Page
模型上的字段 - 因此任何继承自该模型的模型都将具有这些字段,您可以像访问模型上的任何其他字段一样访问这些字段:
seo_title
: Alternate SEO-crafted title, for use in the page’s <title>
HTML tag.
是否在模板中使用它取决于您 - 如果您使用,它将在 HTML head
部分,例如,
<title>{{ page.seo_title }}</title>
search_description
: SEO-crafted description of the content, used for search indexing. This is also suitable for the page’s <meta name="description">
HTML tag.
再次取决于您是否使用它 - 例如,在 head
部分:
<meta name="description" content="{{ page.search_description }}">
创建新页面时,有一个“推广”选项卡。在“搜索引擎”部分下有一个“标题标签”和一个“元描述”值。据我了解,“标题标签”设置文档的标题,“元描述”设置文档的元描述。但是我如何在我的页面模板中实际使用这些值?
我进行了广泛的搜索,但似乎 Wagtail 的文档没有解释任何关于“推广”选项卡或其用途的内容。那里定义的值是否可用作模板变量?我将如何实际访问页面的“标题标签”或“元描述”?
这些字段是 documented very briefly here。它们只是基础 Page
模型上的字段 - 因此任何继承自该模型的模型都将具有这些字段,您可以像访问模型上的任何其他字段一样访问这些字段:
seo_title
: Alternate SEO-crafted title, for use in the page’s<title>
HTML tag.
是否在模板中使用它取决于您 - 如果您使用,它将在 HTML head
部分,例如,
<title>{{ page.seo_title }}</title>
search_description
: SEO-crafted description of the content, used for search indexing. This is also suitable for the page’s<meta name="description">
HTML tag.
再次取决于您是否使用它 - 例如,在 head
部分:
<meta name="description" content="{{ page.search_description }}">