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
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
The formatter configuration looks as follows:
Now you can map your wanted information to the meta-tags by using the corresponding EL call in the header of your template.
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.