You can use the <cq:includeClientLib> in combination with themes and / or categories to mix and match CSS bits.
But you may find that this is somewhat limiting; for example, you cannot specify a media attribute. If you need to do this, or your designers do not structure their CSS in a way that suits the theme / category model, your reserve is the method that you defined in your question using <link> directly.
Update
Great question about topics! I just saw how they were used along the way.
You can define a theme by simply adding a new folder / node under /etc/designs/yourproject/clientlibs/themes , as a brother to default .
You can pull out client sheets for a topic with the <cq:includeClientLibs> , possibly under the control of some conditional logic. For example, in one of my projects, I have a topic called authoring that I want to apply only to the authorโs instance; I embed it with this code in headlibs.jsp :
<c:if test="${ (global['wcmmode'] eq 'EDIT') || (global['wcmmode'] eq 'PREVIEW') }"> <cq:includeClientLib theme="apps.myproject.authoring" /> </c:if>
I have not seen any documentation that would automatically apply a theme to a separate subtree of the content tree or based on the presence of a tag.
There is such a critical operator: "The topic name is retrieved from the request." in Adobe docs backed up by this statement in Sling docs , ThemeResolverFilter provides a subject for the request. The theme is provided as a request attribute. "Therefore, perhaps binding &theme=apps.yourproject.foo to the query string would apply this theme.
source share