Sharing Content in 7.4...

Say goodbye to the Global site and hello to Asset Libraries...

Introduction

Recently I was pulled into a client project that was created for Liferay 7.4 and they needed to share content, structures, templates, documents, etc with multiple sites.

Then I found out that they had done this the old way using the Global Site, and I was like "No No No, we have to fix this, we have to use Asset Libraries!"

And everyone just stared at me, and I could tell just by the looks on their faces, they were asking "What's an Asset Library?"

What's Wrong With The Global Site?

So for review, let's start a basic Liferay site. In Liferay, you always have at least one primary site. When you first start up Liferay and you end up on http://localhost:8080, this is the initial site. It's also commonly accessed via /web/guest, and guest happens to be the site name in URL form (and yes it's always called Guest because it is meant to be the initial public site where all unauthenticated users will start from).

You are free to add more sites into the system, and each site can have assets such as web contents and documents.

As an Administrator or a Site Administrator (or any site role with escalated privileges), you get access to the left side flyout where you can find the Design menu, the Site Builder menu and, for the purposes of this blog, the Content & Data menu. Content & Data is where you find your Web Contents, your Documents, Blogs, etc.

All of these assets, though, they really should only be used by the site they are part of. While it is possible to share assets from the site, it can wreak havoc on your asset permissions.

But most sites typically need to share some content. Often times it is foundational things like web content structures and templates, categories and tags, but it can also include web contents in general too.

The classic way to accommodate this has been the Global site. The Global site is a special site in Liferay that shares content with all sites. Have a structure and template that all sites should use? Put it into the Global site. Shared categories and tags? Put those in the Global site too. If you needed to share some piece of content, the Global site was where you would turn to make this happen.

While the Global site works to share assets, it's also quite broken too:

  • Assets in the Global site can be used by any and all sites, no exclusions.
  • Managing roles and permissions to grant the proper people the proper access to create, edit or delete the proper subset of assets in the Global site can be an administrative nightmare.
  • Without care, since there is only one Global site, it can turn into your kitchen junk drawer - it starts to contain all the odds and ends that you didn't know what else to do with and just end up stuffing them in there.

Although the Global site can share assets, with these other problems, there just had to be a better way...

Enter The Asset Library

Liferay set out to solve the problems with the Global site and in 7.3 they introduced Asset Libraries. In 7.4, though, they have gotten so much better...

Asset Libraries are pretty much exactly what they sound like - a Library containing a set of Assets (web contents, structures, templates, etc.).

Like the Global site, an Asset Library can share all of the assets it contains, but unlike the Global site, an administrator can select which sites can use the assets in the Asset Library.

An Asset Library can have its own defined set of content creators and editors which are able to manage the assets of specific Asset Libraries. So, for example, if you have an Asset Library for HR and another Asset Library for Finance, the folks with the ability to manage the assets in each Library can be completely different, and the controls are defined at the Asset Library as a whole, so they are much easier to set up and maintain (Asset Libraries still allow the same kind of fine-grained access control you have in a site, so you can have different permissions on different roles for different D&M folders if you need to).

Since you can define any number of Asset Libraries, you can organize your assets in a way that would prove difficult for the single Global site.

My Recommendations for Asset Libraries

After working with Asset Libraries for some time now, I've developed one recommendation for Asset Libraries that I wanted to share with you all:

Don't store assets in Sites, store assets in Asset Libraries!

Note here that I don't distinguish between one of the regular Liferay sites or the Global site.

I really feel you will be better served if you use Asset Libraries to hold all of your assets, and never really store the assets in a site at all.

The Asset Libraries are just so useful and they solve so many problems, problems you may eventually have even using the regular sites to store assets.

Any time you can see requirements forming like one group of people can update this set of assets but this other group manages this other subset, this is an example of how an Asset Library can enforce this easily.

And of course cases where you need to share assets between two or more (or all) sites, obviously an Asset Library will be good for this, but especially when the assets will be shared with a subset of sites.

Asset Libraries support Staging, Publications and Workflows. Workflows, in fact, can be defined explicitly as part of the Asset Library, so each library can use different workflow processes.

For Staging, Asset Libraries publish independently of the sites they are connected to. So if you have Staging enabled on your site, you will also have to enable Staging on the Asset Libraries that site can use, but they each can publish independently of each other. One set of admins can maintain the site, create pages, etc and publish those, and a completely different set of admins can manage and maintain the assets in the Asset Library and publish those when they are ready.

For Publications, you have to remember that publications are not scoped, meaning a publication does not only collect changes in one site or an Asset Library. When you start a publication and make a change in a site, switch over to different Asset Libraries and make changes in those, and even hit the Global site and make changes, all of those changes are under the one publication, and they all publish as one big unit of changes.

What About Sharing Fragments and Other Artifacts

Asset Libraries are super useful for sharing web contents, documents, etc.

The only way to share design resources like fragments, Style Books, templates, page templates, etc if through the Global site.

:-(

However, Liferay has recognized that the awesome power and flexibility of Asset Libraries would be just as beneficial with the creation of Design Libraries.

With a Design Library, you'll be able to define a set of shared fragments, templates, and other design resources, you'll be able to choose which sites the design resources would be available in, and they can be permissioned and managed separately in the same way Asset Libraries can.

Although it is not done yet, and I have no real ETA, my hope is that we'll see it sometime in early 2024. By providing the same kind of value that an Asset Library does, I'm hoping Liferay will prioritize it and make it happen sooner rather than later.

If you want to follow along on the progress, the ticket is https://liferay.atlassian.net/browse/LPS-155674

And, if you're a DXP, LXC or LXC-SM/DXP Cloud customer, I'd encourage you to open a support ticket and let them know that you're interested in seeing the Design Libraries added into the product. Just include the Jira ticket when you open the Support ticket and that will add you to the list of interested clients.

Conclusion

Well hopefully you see just how great Asset Libraries can be.

I'd recommend reading more about Asset Libraries from the Liferay documentation:

And remember the Asset Libraries recommendation:

Don't store assets in Sites, store assets in Asset Libraries!

And once Liferay delivers on the Design Libraries, there will be a corresponding recommendation:

Don't store design resources in Sites, store design resources in Design Libraries!

Anyway, feel free to hit me up with your Asset Library questions or problems, I'm more than happy to help spread their adoption...

Blogs

Hi,

I really like the idea of the asset libraries. Since we have a site with many webcontents, is there a way to move the existing webcontents (and structures and templates) automatically from a site to an asset library?

Best Regards, ​​​​​​​Andreas