Dynamic SEO Meta Data
Broadleaf Commerce provides the ability to supply dynamic meta data when rendering Products, Categories, and PageDTOs.
Leveraging the SeoVariableExpression.java
from the context of a Thymeleaf template, we can gather all of the relevant SEO properties for the given Product, Category, or PageDTO. The values for these properties are gathered directly from the object's data via the SeoDefaultPropertyServiceImpl.java
. On the other hand, these values can be overridden on an item-by-item basis. For example, if we wanted to override the meta description for a particular Product, then we would need to provide a ProductAttribute with a name of "metaDescription" and value of "my overwriting value". The same pattern is applicable for CategoryAttributes and PageAttributes.
Alternatively, if you're using a frontend technology other than Thymeleaf, then you should make use of SeoPropertyServiceImpl.java
to gather meta properties.
Out of box, Broadleaf provides a simple implementation for gathering the page's title and meta description from the provided domain object (Product, Category, or PageDTO). If you wish to expand the scope of the meta data gathered from these objects, then you should override BasicSeoPropertyGeneratorImpl.java
to include additional properties. Additionally, if you're an Enterprise customer, then you have access to our SeoPropertyGenerator
implementations that provide support for Open Graph and Twitter Card properties.
See Dynamic Titles and Meta Descriptions for details on how to customize your Product & Category titles and meta descriptions.