Go to main content

Meta description



<txp:meta_description />

The meta_description tag is a single tag used in a variety of ways to display meta description content. One is to output description text as the content of a standard HTML <meta> tag in the <head> of a page template:

<meta name="description" content="{your description}" />

The other is to output raw description text anywhere else:

{your description}

The tag is context aware, in that it will use article descriptions (if available) on individual article pages, and use section and category descriptions (again, if available) on listing pages. The tag can be added directly in page templates or as part of ‘article’ type form templates. Either way, you may also use it in a given article tag.

Note: The corresponding description field has a 255 character limit by default, which includes spaces and punctuation. This is the MySQL database default. You can edit the default using phpMyAdmin, for example.


Escape HTML entities such as <, > and &.
Values: See the tag escaping documentation for all possible values.
Default: html.
Display as <meta> tag or as raw value.
Values: meta or unset.
Default: meta (display as a <meta> tag).
The context from which to display meta information.
Values: article, section, or category. The category may also be augmented to include its type, e.g. category.image or category.file to display description information from the nominated category type.
Default: empty (i.e. automatic, depending on where the tag is used).


Example 1: Use article or section’s description for meta tag content

  <title>Example 3 page</title>
  <txp:meta_description />

The meta_description tag returns an HTML meta tag, populated with an article’s description if the visitor is viewing an individual article. If viewing an article list (landing) page, the tag will return the description from the Section instead.

The tag should normally be placed in your template’s ‘head’ section, between the opening and closing HTML <head> tags.

The above will output description metadata with content=" populated with the text set in the article or section’s ‘Description’ field (the tag returns nothing if no description is set for either).

Example 2: Use article’s description for Twitter Card description (without meta tag)

    <meta name="twitter:description" content="<txp:meta_description format="" />" />

The above will output the description as a raw value (not enclosed in a <meta> tag) populated with the text set in the article’s ‘Description’ field.

Other tags used: if_individual_article.

Example 3: Display section meta description as tooltip in section list

    <a href="/<txp:section />" title="<txp:meta_description format="" />">
        <txp:section title="1" />

Other tags used: section_list, section.

Example 4: Override automatic type

    <txp:meta_description />
    <txp:section title="1" />
        <txp:meta_description type="section" format="" />
<txp:article />

The first time the tag is used in the <head>, the section meta description will be output as a <meta> tag if viewing the section landing page, or the article meta description if viewing an individual article.

The second instance is only shown if on a landing page, and will force the display of the section meta description as an introductory paragraph.

Other tags used: section, if_article_list, article.


Version 4.6.0

Tag support added.

If you notice any kind of problem with this page's construction or content (outdated information, typos, broken links, or whatever), open an issue to have it sorted. Or have a go at it yourself. :)