The Broadleaf Commerce framework provides a number of SEO related features including the following.

  • SEO friendly URLs
  • SiteMap generation
  • Robots.txt maintenance
  • URL Redirect maintenance
  • SEO Meta-Data
  • Optimized CSS and JavaScript

SEO Friendly URLs

Custom Pages, Products, and Categories can all be maintained in the Broadleaf admin. Each of these has a URL property that allows the admin to specify an SEO friendly URL.

The URLs are handled via custom URL handlers. Namely, CategoryHandlerMapping. These classes all implement the Spring MVC - AbstractHandlerMapping allowing them to delegate matching URLs to the related controllers (for example PageController).

These handlers execute in the following order (Product, Page, Category).

SiteMap Generation

For many sites, the sitemap is an important part of the SEO strategy. Broadleaf provides a configurable, extensible pattern for generating your sitemap.xml file.

The structure for sitemaps is a standard maintained at

A simple version from the website follows:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="">

Notice the url element in the example above. An eCommerce site could have a large number of these (1 for each product). The sitemap specification indicates a maximum of 50,000 entries per file which results in the need for "indexed" sitemap files. An example from follows ...

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="">

Broadleaf provides components to generate the sitemap based on the products, categories, and pages that you have setup in your system. Other url entries can be built by creating your own custom SiteMapGenerators following the same approach.

The default implementation automatically indexes the files if needed.

The approach centers on SiteMapGenerator components which are responsible for generating individual URL elements.

The key components involved are ...

Component Name Component Description
SiteMapService The primary process that is responsible for building the sitemap
SiteMapBuilder Helper class responsible for much of the file processing
SiteMapGenerator Responsible for building url entries for the sitemap
BroadleafSiteMapController A basic controller to render the SiteMap

In addition, the system provides the following generators out of box ...

Generator Name Purpose
PageSiteMapGenerator Builds the url entries for pages
CategorySiteMapGenerator Builds the url entries for categories
ProductSiteMapGenerator Builds the url entries for products
CustomUrlSiteMapGenerator Defines custom url entries

Each of these components can be overridden and additional for implementation specific behavior and more complex implementations are likely to need custom SiteMapGenerators.

The default Broadleaf Implementation will generate the sitemap when it is first requested for each application server and utilize that generated version for the next week. The amount of time between generations is controllable by a property on SiteMapService. It is recommended that for sites with large catalogs, the sitemap is generated offline as part of a scheduled job rather than having it generated on request.

Robots.txt maintenance

Broadleaf allows you to maintain your robots.txt file in the Broadleaf Admin. Simply create a page named '/robots.txt' and it will be served when requested.

This is accomplished via the BroadleafRobotsController. The Broadleaf Demo Site provides an example usage with the RobotsController implementation.

Note that the name and location of the sitemap.xml file should match your SiteMapController and SiteMapGeneratorConfiguration. The out of box defaults work fine for most implementations.

URL Redirect maintenance

The Broadleaf admin provides the ability to create 301 redirects using the URL Redirect maintenance. These URLs can be manged in the Content Management section of the admin.