Skip to content
OpenCms documentation
OpenCms documentation

Meta mappings

Meta mappings allow you to export information specified in a content to any formatter of a page or the template of your site. Meta mappings are executed before the JSP is rendered, thus, you can call the meta information of your content from any point of the same page. Meta mappings are defined in formatter configurations.

The primary usage of meta mappings is to generate HTML <meta> tags in the <head> section of a template JSP. Meta mapping definitions select information such as the title, the description, and an image from a content and bind this information to a meta information map. Keys and values from this meta information map can then be read in the template JSP or in any formatter JSP.

Meta mappings in OpenCms by default are active for detail pages only. On a detail page, it is clear which of the contents on a page is the main content and thus which meta information to export via HTML <meta> tags for the public. On container pages containing different content types or even lists with many contents of the same type, the main content cannot be identified in an easy way. There is a rank property available in meta mapping definitions to rank some mappings higher than others. For container pages, though, it is better practice to provide an extra meta information content that should be manually inserted on a page by the content editor.  

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, there is a meta mapping configured. The value in the "Key" field will be used to access the mapping, the "Path" field defines which value should be mapped. The value can then be read in a JSP with the expression ${cms.meta.[Key]}.

The formatter configuration looks as follows:

Add a meta mapping via formatter configuration

You can insert the value of the ogTitle meta information into the <head> section of your template the in the following way:

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

Meta mappings by default are available for detail pages only. If there are reasons to do this, meta mapping definitions can be switched on for container pages too by choosing the option "always apply meta mappings".

Meta Mapping Checkbox