Filling HTML Meta tags on article pages

The goal of this example is to populate the meta tags on our page with the list of keywords associated with the article as well as the names of the authors.

If you want to optimise the indexing of your site by search engines, you can, for example, include the description of the article, the associated keywords and the name of the authors in special tags, called "meta tags" which are located in the HTML document’s header and not normally visible to casual site visitor.

SPIP enables you to fill out these fields for each page on your site quite automatically, for example, using the article’s description, any keywords associated to that article, as well as the name(s) of the article’s author(s).

Meta tag examples filled by SPIP
Action HTML/SPIP syntax
Page title <title>[(#NOM_SITE_SPIP|textebrut)]</title>
Description [<meta name="Description" content="(#INTRODUCTION|couper{200}|textebrut)" />]
<meta name="Keywords" content="<BOUCLE_keywords(MOTS) {id_article} {","}>[(#TITRE|textebrut)]</BOUCLE_keywords>" />
Authors [<meta name="Author" content="(#LESAUTEURS|textebrut)" />]
Application name <meta name="Generator" content="SPIP[ (#SPIP_VERSION)]" />
Webmaster’s e-mail [<meta name="Reply-to" content="(#EMAIL_WEBMASTER|textebrut)" />]

Do not forget to apply the filter textebrut on the SPIP tags to remove any tags, paragraph marks and spaces that don’t belong here. Also, stay within the limits of the number of characters requires by each meta tag, using the couper filter.

Note here that we’ve used an embedded loop structure to retrieve the keywords based on the current id_article. In addition, we have specified the comma as a separator so that the meta tag contents make sense (including being understood by the search engines).

These meta tags are not essential to the indexing of the site. On the other hand, do not forget the page title, which is still important especially because it identifies each page of your site in the search engine results.

Here is the full example for the article template (to be placed in a ARTICLES loop within the head tags of the page

You can adapt this example to other kinds of elements such as sections, news items, etc.

Author George Published : Updated : 26/10/12

Translations : عربي, català, English, Español, français, italiano, Nederlands, українська