From Textpattern CMS version 4.6, meta data is changing. For too long, we have relied on plugins or custom fields to prop up the meta description tag. Unlike keywords, it’s a ubiquitous piece of meta data that search engines use to summarise our sites. So we now have a dedicated textarea for description content, not just at the article level but for Sections and Categories too.
Twisting down the ‘Meta’ area in the ‘Write’ panel reveals the new text area where you may write your article summary. Editing a Section name or Category (for any content type) reveals a similar textarea. Go nuts and describe your stuff… well, in under 255 characters.
But the descriptions are no good without the means to display them, and to that end two new tags have appeared:
<txp:meta_description> is a multi-purpose tag that allows you to output description content. By default it is context dependent—that is, it tries to be smart about what it shows depending on where you place the tag and/or what the visitor is looking at. If you put it in your Page
<head> and a visitor views an individual article, the tag will render the full article description as a
<meta> tag. If, however, a list (landing) page is being viewed, the Section description will be displayed instead.
Similarly, if you use the tag inside a
<txp:section_list> Form or container, the Section description will be displayed. In these cases though, you probably don’t want the full
<meta> tag experience, so you can employ
format="" to output the raw description content. This flexibility allows you to display the description as a tooltip, or as an introductory paragraph to your landing page, or as a custom
<meta> tag for a Twitter feed or Facebook OpenGraph definition.
If used inside a
<txp:category_list> Form or container, or when viewing a
/category of content, the appropriate category description will be available instead.
For those times when you want to do something out of the ordinary or override the automatic context detection, you can use the
type attribute. This allows you to display the
section or (context-aware)
category anywhere you like on your page. You can also override the category context by using a special dot-syntax:
type="category.image" for example, will show the description from the current image category.
If at any time the tag encounters no description content, the tag outputs nothing. This is handy, but if you wish to go beyond this, a companion tag
<txp:if_description> permits content to be displayed conditionally. And it’s compatible with
<txp:else /> allowing you to render default content in those instances where description info is missing.
Keyword and author metadata
To coincide with the launch of the new tags, a few other changes have taken place. Up until now, Textpattern has had two tags for displaying keywords:
<txp:meta_keywords>. From 4.6 onwards, the former tag is deprecated.
To compensate, the latter tag has been beefed up. So everywhere you had:
you just replace it with:
<txp:meta_keywords format="" />
Yes, on the surface it seems like more typing, but it has one fringe benefit in that you are no longer forced to use
<txp:if_keywords> to detect if the article has keywords, as the tag will simply render nothing if there are none. No warnings, no fuss.
<txp:meta_keywords> tag also has a new
separator argument allowing you to output the list delimited in any manner you wish. If you wanted to use comma-space or even HTML tags between each item, you now can.
<txp:author /> tag has a
format attribute too, which allows you to output the article author as a:
link(which is the same as using
link="1") to render a hyperlink to the author list page.
urlto return the raw anchor to the author list page, for building your own links.
- name/title (using
<txp:meta_author> tag remains largely unchanged, though it accepts a
format attribute to choose between outputting a
<meta name="author"> tag (the default) or raw author name/title.
All the above tags also now accept the
escape attribute so you have the option to output the content without any HTML entities being converted. This is handy if you want to permit HTML character sequences to be passed to the page unscathed, or perhaps if using the tags as attributes to other tags.
If you can’t wait until release or are genuinely curious, you can try it out by cloning or downloading the development master. Please raise any views or concerns over the functionality on the support forum thread, while bug reports should be directed to the issue queue.
We hope the new tags and capabilities will simplify you and your clients’ workflows, allow you to do things that weren’t easily achievable before, and place less reliance on plugins to render what is—and arguably always should have been—core functionality.