The Broadleaf Commerce framework provides a number of SEO related features including the following.
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
These handlers execute in the following order (Product, Page, Category).
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 sitemaps.org.
A simple version from the sitemap.org website follows:
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://www.example.com/</loc> <lastmod>2005-01-01</lastmod> <changefreq>monthly</changefreq> <priority>0.8</priority> </url> </urlset>
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 sitemap.org follows ...
<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap> <loc>http://www.example.com/sitemap1.xml.gz</loc> <lastmod>2004-10-01T18:23:17+00:00</lastmod> </sitemap> <sitemap> <loc>http://www.example.com/sitemap2.xml.gz</loc> <lastmod>2005-01-01</lastmod> </sitemap> </sitemapindex>
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 ...
|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.
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
Note that the name and location of the
sitemap.xmlfile should match your
SiteMapGeneratorConfiguration. The out of box defaults work fine for most implementations.
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.