Brightspot CMS Developer Guide


Brightspot provides APIs for managing URLs and generating permalinks automatically.

Brightspot provides the Directory class for managing URL paths to Content-based objects stored in the database. Directory and its inner classes provide several APIs to support URL pathing.

Use Directory.Static.hasPathPredicate to verify that an object has a URL path, for example:

Query query = Query.from(Article.class).where("_id = '00000161-d80b-ddd6-a37d-fc3bb47a0000'");
Article article = (Article) query.where(Directory.Static.hasPathPredicate()).first();
if (article == null) { /* Set a URL path */ }

Use Directory.ObjectModification#addPath to set a URL path on an object, for example:

Article article = new Article();
article.setHeadline("Hurricane-force Winds on Mt. Washington");
String path = StringUtils.toNormalized(article.getHeadline());, Directory.PathType.PERMALINK);

In the above snippet, the addPath method takes parameters for the URL path and the path type. The path is formed from the headline of the article, and the path type is specified with the Directory.PathType enumeration. PERMALINK is a link that never expires. See Content URL types for a description of all URL options.

An object can have different paths for different sites. The addPath method creates a path for the site that owns the object. If you have multiple sites, you can use the addSitePath method to create a path that is associated with a specified site.

The following code extends the above example, adding the path before the object is saved. The addSitePath method creates a path to the object for a second site, News.

public void beforeSave() {
    List<Site> sites = Query.from(Site.class).selectAll();
    for (Site site : sites) {
        if (site.getName().equals("News")) {
            String path = StringUtils.toNormalized(this.getHeadline());
                     .addSitePath(site, "news//" + path, Directory.PathType.PERMALINK);
In order for an object’s site-specified path to work, that site must be given access to the object; otherwise, the object is not visible to the site. For more information on site ownership and access, see Permissions and multiple sites.

The URLs widget in an object’s content edit page shows assigned URL paths. For the article example, there is a path for the owner site, Global, and for a second site, News.

URLS widget with custom permalinks URLS widget with custom permalinks

Brightspot provides the Directory.Item#createPermalink method to automatically generate permalinks for a specified site. For example, the following method implementation in the Article class creates a permalink for each instance of the class, based on the instance headline.

public String createPermalink(Site site) {
   return StringUtils.toNormalized(getHeadline());

Implementing createPermalink in a class is reflected in Brightspot. When you create an instance of the class, the Generate Permalink option appears in the URLs widget on the content edit page. Continuing with the Article class example, the permalink shown in the widget is based on a user-entered headline for the article.

Rendered custom permalink Rendered custom permalink

Previous Topic
Visibility labels
Next Topic
Was this topic helpful?
Thanks for your feedback.
Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

Asset types
Module types
Page types
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

Content types
Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

Field types
Content modeling
Rich-text elements
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

Google Analytics
Apple News