Jun
22
Create Textpattern meta description
June 22, 2008 |
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.
1. Navigate to the Preferences -> Advanced Preferences tab.
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.
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.
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.
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!
Similar Posts
Comments
2 Comments so far



































thanks! it takes me a while to figure it out, it works like a charm!
i think there are plug-ins that do a similar job.