Textpattern:创建页面Meta描述

此方法针对旧版Textpattern创建Meta Description 有效,新版Textpattern因为在后台发布文章时已经提供了Description 字段输入,此方法已经冗余。 by 涉水轻舟 Update 2017.12.17

This tutorial teaches you how to create custom dynamic meta description in Textpattern for each individual section and article. The instruction is a bit long, so if you got any problem, just ask by posting a comment.
这里将教会你如何在Textpattern中为每个独立的科目及文章创建动态的Meta描述。本文有点长,如果你有任何问题,欢迎留言评论。

1. Navigate to the Preferences -> Advanced Preferences tab.
进入后台管理茶菜单下的Preferences -> Advanced Preferences选项卡

2. Find the Custom Fields section, which is the fourth section down on the page.
找到【自定义字段】

3. You’ll notice that by default, custom fields 1 and 2 are set up and named custom1 and custom2, respectively. Change the custom1 to meta_desc.
你将注意到几个默认设置,自定义字段1和2的名称被分辨设置为自定义1和自定义2。那么你可以修改自定义1为meta_desc.

4. Click the Save button at the bottom of the page to store the new custom field names to the database.
设置好之后单击【保存】按钮存储该设置到数据库中。

5. Navigate to Presentation -> Forms tab.
去到导航Presentation -> Forms 标签

6. Click on Create new form link at the top of the right hand sidebar.
单击右栏顶部的【创建新表单】

7. In the textarea, type:
在文本区输入:

<meta name="description" content="<txp:custom_field name="meta_desc" />" />

8. Add value meta_dynamic to the Name (required) field.
在表单名(必填)中输入mete_dynamic 。

9. Select article from the Type (required) dropdown menu.
通过下来选项为该文章表单选择类型(必填)

10. Click the Save button at the bottom of the page to store the new custom field names to the database.
单击底部的【保存】按钮存储自定义表单到数据库中。

11. Again click on the Create new form link at the top of the right hand sidebar.
再次单击右栏顶部的【创建新表单】

12. At this point, you may make a choice between the following two options depend on the way you layout your site structure.

a) Now if you use the default section as front page, type:

<txp:if_section name="">
  <txp:article_custom section="default" status="sticky" form="meta_dynamic" />
<txp:else />
  <txp:if_individual_article>
    <txp:article form="meta_dynamic" />
  <txp:else />
    <txp:article status="sticky" form="meta_dynamic" />
  </txp:if_individual_article>
</txp:if_section>

b) Now if you have a front page belongs to a section other than default section page, for instance ‘homepage’ section is your front page, In the textarea, change the second line above:

<txp:article_custom section="default" status="sticky" form="meta_dynamic" />

to

<txp:article_custom section="homepage" status="sticky" form="meta_dynamic" />

13. Add value meta to the Name (required) field.

14. Select misc from the Type (required) dropdown menu.

15. Click the Save button at the bottom of the page to store the new custom field names to the database.

16. Naviagte to Presentation -> Pages, insert the following line at the head section of all template pages.

<txp:output_form form="meta" />

17. Navigate to the Admin -> Content -> Write tab.

18. Click the Advanced Options link at left to expand the menu.

19, under meta_desc, put in the meta description

19. If the article is an individual article, just select the section and category it belongs to. Else if you are writing the meta_desc for a section page, under Status, choose sticky, and select the section it belongs to, you can leave the main content empty.

20. After adding in meta_desc for all section and individual pages, just go to the site, view source, and the meta description should be rendered.

I know the instruction is a bit long, so if you got any problem, just write a comment. I will be more than happy to help!

via: 查看原文
翻译: 涉水轻舟

评论已关闭。Comments are turned off for this article.