Dynamic Title and Meta Descriptions
Broadleaf Commerce provides the ability to specify both values and patterns for title and meta description elements on product and category pages. This includes three features:
- Site-level pattern definitions
- Category-level Product pattern overrides
- Title and description value overrides
Site-level Pattern Definitions
Using either your common.properties
or the System Property section of the admin interface, you may specify the patterns that will be used to dynamically create titles and descriptions for product and category pages.
For example, you may wish for each category page to have a title like the following:
<title>Hot Sauces - The Heat Clinic</title>
To achieve this, you would need to use the following pattern:
#seoElement.buildTitleString({#seoElement.getTitle(category), #brc.site.name}, ' - ')
The #seoElement.getTitle(category)
portion gathers the Category title, while allowing for overrides of this particular portion of the overall pattern. The #brc.site.name
portion simply gathers the current site's name. Finally, #seoElement.buildTitleString
appends each element in the list, using ' - '
as the separator between each portion.
As previously mentioned, you have the ability to set these patterns for product title, product description, category title, and category description. The fields are named as follows:
Name | Description |
---|---|
seo.product.title.pattern |
Product Title Pattern |
seo.product.description.pattern |
Product Description Pattern |
seo.category.title.pattern |
Category Title Pattern |
seo.category.description.pattern |
Category Description Pattern |
Category-level Pattern Overrides
Broadleaf also offers the ability to override the product title pattern and product description pattern at the category level. In order to set a title or description pattern for all products in a certain category, take the following steps:
- Login to the admin interface and navigate to the Category section
- Navigate to the desired Category's edit form
- Under the
MISCELLANEOUS
section of this form, you'll be able to edit thePRODUCT TITLE PATTERN OVERRIDE
andPRODUCT DESCRIPTION PATTERN OVERRIDE
fields
Title and Description Value Overrides
The patterns described above can contain calls to the SeoElementVariableExpression
. The available methods include #getTitle(Product product)
, #getDescription(Product product)
, #getTitle(Category category)
, and #getDescription(Category category)
.
The two title methods will by default return the name of the product or category respectively. The description methods will return an empty string if a value is not found. However, you have the ability to override these values using the following steps:
- Login to the admin interface and navigate to the Product section
- Navigate to the desired Product's edit form
- Under the
MISCELLANEOUS
section of this form, you'll be able to edit theMETADATA PATTERN OVERRIDE
andMETADATA DESCRIPTION OVERRIDE
fields
Note: The Category fields can be found in the
MISCELLANEOUS
section of a Category's edit form.
Usage
To better understand how to make use of this data please see the Dynamic SEO Meta Data document.