Referencing location of files in theme-resources/resources

539 views
Skip to first unread message

Garth

unread,
Jan 18, 2022, 2:15:32 PM1/18/22
to keyclo...@googlegroups.com
Crossposting from here: https://keycloak.discourse.group/t/location-of-theme-resources-resources/13135

From the documentation about Theme resources (https://www.keycloak.org/docs/latest/server_development/#_theme_resource):

> 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?

Thank you!

Garth

Thomas Darimont

unread,
Jan 18, 2022, 3:22:34 PM1/18/22
to Garth, Keycloak User
Hello Garth,

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.

Cheers,
Thomas

--
You received this message because you are subscribed to the Google Groups "Keycloak User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-user/805efd66-d5e6-4f71-974a-269d1a4d402d%40www.fastmail.com.

Garth

unread,
Jan 18, 2022, 3:25:34 PM1/18/22
to Thomas Darimont, keyclo...@googlegroups.com
Wow. Great sleuthing. As you say in your post, it's a "hack", but works! Thanks for the workaround.
>> To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com <mailto:keycloak-user%2Bunsu...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages