OpenCms Documentation

Meta mappings

 Show GitHub edit links  Hide GitHub edit links
In OpenCms since: 11.0.0 Documented since: 11.0.0 Latest revision for: 11.0.0 Valid for OpenCms: 11.0.2

Meta mappings, introduced in OpenCms 11, allow you to map information, specified in the content editor, to another element or the template of your site. Since the meta mappings are executed before the JSP is rendered, you can call the meta information of your content from any point of the same page. You simply define in your content editor which information should be mapped. This eases for example the adding of metadata to the head of your detail pages. Here, the required information for the meta-tags is automatically generated from the content and can be transferred to the header of the page. To gain a better understanding of this situation, see the demonstration here.

Meta mappings in practice

You can set the open graph meta tags and Twitter Card tags to adapt the appearance of your website in the social media according to your wishes. Meta mappings are particularly useful for detail pages. With a few small steps, you can give every detail page its own entries in the meta-tags. 

Use case: The header of detail pages

To take a closer look at meta mappings on detail pages, we explain them on a concrete example.

The formatter "Blog article detail view" shall be rendered on a detail page. We want to map the value of the field "Title" of our content element and call it in the header of the template under the <meta property="og:title">-tag . 

In the tab called “Meta mappings” of the formatter configuration,  you can add and configure a new meta mapping. The value in the "Key" field will be used to access the mapping, the "Path" field defines which value should be mapped. You can call the value in the JSP with ${cms.meta.[Key]}.

The formatter configuration looks as follows:

Fig. [formatter_addmetamappings]: Add a meta mapping via formatter configuration

Now you can map your wanted information to the meta-tags by using the corresponding EL call in the header of your template.

    <!--  -->
    <meta property="og:title" content="${cms.meta.ogTitle}">


When multiple contents with meta information appear on the same site, for example in a list, the problem occurs, which meta mappings should be performed. To avoid the issue, a checkbox was added to prevent the meta mappings. Is this box unchecked, the meta mappings are applied only if that formatter is used on a detail page for the detail content.

Fig. [formatter_metamappingscheckbox]: Meta Mapping Checkbox

You can improve this page

Please contribute your suggestions or comments regarding this topic on our wiki. For support questions, please use the OpenCms mailing list or go for professional support.