Meta Tag Rules: Site Integration

Use the following APIs to obtain page meta tags that are generated based on rules:

You can then add them into your dw.web.PageMetaData container to have them available in your header generation, as shown in this example:

updatePageMetaTags: function (object)
 {
   if ( object.class === dw.content.Content
       || object.class === dw.system.Site
       || object.class === dw.catalog.Product
       || object.class === dw.catalog.ProductSearchModel
       || object.class === dw.content.ContentSearchModel)
   {
       var pageMetaData = request.pageMetaData;
       pageMetaData.addPageMetaTags(object.pageMetaTags);
   }
 },

The dw.web.PageMetaData container supports a loop approach, creating all your page meta tags in an easy way:

 <iscomment>Rule based page meta tags</iscomment>
 <isloop items="${pdict.CurrentPageMetaData.getPageMetaTags()}" var="pageMetaTag">
     <isif condition="${pageMetaTag.title}">
         <title><isprint value="${pageMetaTag.content}"/></title>
     <iselseif condition="${pageMetaTag.name}">
         <meta name="<isprint value="${pageMetaTag.ID}">" content="<isprint value="${pageMetaTag.content}">">
     <iselseif condition="${pageMetaTag.property}">
         <meta property="<isprint value="${pageMetaTag.ID}">" content="<isprint value="${pageMetaTag.content}">">
     </isif>
 </isloop>

The following methods enable you to check if page meta tags are generated and perform fallback behavior:

 <isif condition="${!pdict.CurrentPageMetaData.isPageMetaTagSet('description')}">
     <meta name="description" content="Add here your fallback description!">
 </isif>

Related Links

Meta Tag Rules

Meta Tag Rules Syntax APIs

Creating Page Meta Tag Rules

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.