Meta Tag Rules: Syntax

The rule syntax supports the following different operations that are optimized for page meta tag content generation. Also, script operators are not valid for each scope, for example, site is available for each scope, while category is available for PLP and PDP and not for CLP or CDP, as follows:

The page meta tag rule has both static and dynamic elements. Static elements are printed directly and dynamic elements must be defined within the script syntax: ${dynamic-expression-here}. The dynamic-expression, can contain operators and objects as follows.

Static Text

Static text is typically used with a dynamic element, such as 'Some static text with dynamic part ${expression} here.'

If expression is empty, the content, 'Some static text with dynamic part here.' is generated.

If expression evaluates to 'Dynamic String Value', the content, 'Some static text with dynamic part Dynamic String Value here.' is generated.

Static Text in Dynamic Expression

When creating rules, you can print specific static text if something evaluates true, such as in Constant('constant text').

As an example:

Static text and ${Constant('static text in rule')} here.

Generates as:

Static text and static text in rule here.

Dynamic Text

With page meta tags, dynamic text enables you to access to the Product, Category, Folder, Content, and Site objects and their values. All defined system and custom values are available, except defined passwords and unsupported values, for example:

Product.brand
Product.pageDescription
...
Product.custom.washingInstructions
...

The following script:

Find ${Product.name} in ${Category.displayName} today | ${Site.displayName}

Generates the content:

Find Apple iPod Classic in iPod & MP3 Players today | SiteGenesis' for product 'apple-ipod-classic' in SiteGenesis.

Convenience Objects

Some information is not directly available on the object itself or is only accessible with further effort. For this information, you can use convenience object expressions within the script.

Convenience Object: ProductImageURL

ProductImageURL.viewtype

The following script:

${ProductImageURL.medium}

Generates the content:

https://www.site-genesis.com/on/company.static/-/Sites-electronics-catalog/default/dw32ee7837/images/medium/ipod-classic-silver.jpg'
 for product 'apple-ipod-classic' in SiteGenesis.

Convenience Object: ProductPrice

 ProductPrice.min
 ProductPrice.max
 ProductPrice.currency

The following script:

${ProductPrice.min} ${ProductPrice.currency}

Generates the content:

'199.00 USD' for product 'apple-ipod-classic' in SiteGenesis.

Convenience Object - SearchRefinement

Supports two optional arguments: the delimiter, followed by the text into which the values are added.

 SearchRefinement.refinementID
 SearchRefinement.refinementID(',')
 SearchRefinement.refinementID(',', 'for the refinements ?') ... values are printed into the question mark placeholder

The following script:

${SearchRefinement.refinementColor(' and ', 'for the color ?')}

Generates the content '' for the search page without any selection. If the color black is selected, the content 'for the color black' is generated. If blue is later selected, the content 'for the color black and blue' is generated.

Convenience Object - SearchPhrase

Supports one optional argument that defines the text into which the value is added.

 SearchPhrase
 SearchPhrase('for the search phrase ?')

The following script:

${SearchPhrase('for the search phrase ?')}

Generates empty content for the search page without a search phrase. If the search phrase shoes is added, the content 'for the search phrase shoes' is generated.

Convenience Object - OriginalRequestURL

OriginalRequestURL

The following script:

${OriginalRequestURL}

Generates the following content if this is the request URL:

http://www.sitegenesis.com/mens/

The URL is printed exactly as requested.

OR Expression

The logical OR expression means the left or right side must evaluate true. This expression supports a one-argument constructor, defining the static text printed between the left and right side if both are available.

 leftExpression OR rightExpression
 leftExpression OR(' delimiter ') rightExpression

The following script:

Find ${Product.name OR(' in ') Category.displayName} today | ${Site.displayName}

Generates the content:

'Find Apple iPod Classic in iPod & MP3 Players today | SiteGenesis' for product 'apple-ipod-classic

When the category displayName is removed from the corresponding category, the following content is generated:

'Find Apple iPod Classic today | SiteGenesis'

AND Expression

The logical AND expression, which means the left and right side must evaluate true. This expression supports a one-argument constructor, defining the static text printed between the left and right side.

 leftExpression AND rightExpression
 leftExpression AND(' delimiter ') rightExpression

The following script:

Find ${Product.name AND(' in ') Category.displayName} today | ${Site.displayName}

Generates the content:

'Find Apple iPod Classic in iPod & MP3 Players today | SiteGenesis' for product 'apple-ipod-classic'.

When the category displayName is removed from the corresponding category, the following content is generated:

'Find today | SiteGenesis'

ELSE Expression

The logical fallback expression, which means that if the left side evaluates false, evaluate the right side.

 leftExpression ELSE rightExpression
 expression1 ELSE expression2 ELSE
 expression3 ELSE expression4 ... there is no limit

The following script:

Find ${Product.name AND(' in ') Category.displayName ELSE Product.ID AND(' in ') Category.ID} today | ${Site.displayName}

Generates the content:

'Find Apple iPod Classic in iPod & MP3 Players today | SiteGenesis' for product 'apple-ipod-classic'.

When the category displayName is removed from corresponding category, then the following content is generated:

'Find apple-ipod-classic in electronics-digital-media-players today | SiteGenesis'

IF-THEN Expression

The logical if true, then do something else expression, which means that if the left side evaluates true, then evaluate the right side.

IF leftExpression THEN rightExpression

The following script:

${IF SearchRefinement.refinementColor OR SearchPhrase THEN Constant('noindex,nofollow') ELSE Constant('index,follow')}

Generates the content 'index,follow' if no color is selected and no search phrase is set. If color or search phrase is set, the content 'noindex,nofollow' is generated.

ENDIF Expression

IF-THEN-ELSE expressions now support nesting, using the ENDIF operator as a logical closing element.

IF expression THEN IF otherExpression THEN [...] ELSE [...] ELSE [...] ENDIF ELSE [...] ENDIF

EQ Expression

The logical equals check expression.

leftExpression EQ rightExpression

The following script:

${IF ProductPrice.min EQ ProductPrice.max
 THEN ProductPrice.min ELSE ProductPrice.min
 AND('-') ProductPrice.max} ${ProductPrice.currency}

Generates the content '199.00 USD' for product 'apple-ipod-classic'. For a product with a min price '90' and max price '120', the content '90.00-120.00 USD' is generated.

CONTAINS Operator

The CONTAINS operator indicates a search for any of the specified words or phrases within a particular property. If no operator is specified, the CONTAINS operator is assumed

IF SearchPhrase EQ Constant('shoes') THEN ... ELSE ... IF SearchPhrase CONTAINS Constant('shoes') THEN ... ELSE ...

Related Links

Meta Tag Rules

Meta Tag Rules: Site Integration

Creating Page Meta Tag Rules