Textpattern CMS has a baked-in tag system that provides a raft of functions to website builders and administrators. A subset of these tags are categorised as markup tags. Although they’re gathered under the markup grouping, they vary in their usage and scope. For this series of articles, I’ll be introducing you to and showing you how to use the following Textpattern tags:
Depending on your role on a Textpattern-powered website, you may not have ever have reason to use Textpattern tags. If you’re typically involved with writing and publishing articles, uploading files and/or images, and dealing with website comments then tags can understandably look a bit alien. Out of the box, Textpattern’s default theme uses a bunch of tags behind the scenes to construct pages, articles, feeds, discussions and other things.
Understanding how Textpattern tags extract information from your articles, files, images and discussions will help you better prepare and commit your content. Two tags that relate to articles, for example, are the `meta_author` and `meta_keywords` tags. There are contrasting schools of thought as to whether keywords are becoming more or less relevant to different search engines in current web design best practise, but knowing how the `meta_keywords` tag pulls information from your articles will undoubtedly help you – if you’re not using keywords at the moment, you may start to use them more regularly and if you are taking time to populate the box with keywords, you will likely fine-tune how to do it.
Firstly, though, I’ll explain how `meta_author` works. It’s a single tag that’s used in the `<head>` of a page to associate an author with a given article. To give a very simple example:
<head> <txp:meta_author /> </head>
In the rendered page output for an article written by Alice Scoggins with a username of `alice`, that then becomes:
<head> <meta name="author" content="alice" /> </head>
Note that the author’s attribution is her username. Used as-is (i.e., without any attribute), the `meta_author` tags outputs the username of the author. To have the full name of the author present, simply add the `title` attribute with a value of 1. Like this:
<head> <txp:meta_author title="1" /> </head>
This then becomes:
<head> <meta name="author" content="Alice Scoggins" /> </head>
The `meta_keywords` tag works in a similar fashion inside the `head`:
<head> <txp:meta_keywords /> </head>
There are no attributes. It’s smart enough to follow some logic, however:
- if there’s content in the article keywords field, it will output the contents
- if there’s no content in the article keywords field, it will do nothing
Blending the two tags together, and using Alice’s article with keywords of `oranges,apples,lemons`, the following tag construct…:
<head> <txp:meta_author title="1" /> <txp:meta_keywords /> </head>
… will look like this on the page source:
<head> <meta name="author" content="Alice Scoggins" /> <meta name="keywords" content="oranges,apples,lemons" /> </head>
Next time: a triple header of `site_name`, `site_slogan` and `site_url`.