The easiest way to load additional theme resources is to create a JAR with templates in theme-resources/templates resources in theme-resources/resources and messages bundles in theme-resources/messages and drop it into the standalone/deployments/ directory of Keycloak.
I have a js and css file in theme-resources/resources that I want to reference from my .ftl in theme-resources/templates. When I’m building a login theme, this is achieved by using ${url.resourcesPath}, but that doesn’t work in this case.
Does anyone know the path I can use to reference resource files in theme-resources/resources?
I stumbled upon this very same problem a few years ago and couldn’t find a direct way to solve this back then, and I think it’s still not explicitly supported at the moment.
However, I found another way of providing extension specific resources by shipping a custom theme with the extensions with the resources. This gives you a predictable name to refer to resources.
However I think the resource lookup should be extended to also be able to lookup resources from the themes-resources folder of an extension jar. This would make it much easier to ship self-contained extensions with UIs.
Following Thomas’s post, I also was able to use the extension-specific theme idea along with a custom resource to render the resource url without a relative ../..