Best practices for managing CSS, JavaScript, images?


I’m just ramping up on Radiant. Apologies if I’ve missed this in a
FAQ somewhere, but I’m looking for some recommendations on managing
these types of assets on a Radiant-based site. I found a mailing list
thread from 2006, but it didn’t seem to have a conclusion.

With non-Radiant sites I have Apache serve up these static files,
bypassing Rails entirely. What are the recommended best practices
with Radiant? I’d like to manage them through the web interface, so
that other folks don’t have to deal with Subversion, deployment, etc.

Do folks generally just embed the CSS and JavaScript in a layout and
serve it dynamically? And caching?

What about images (icons, backgrounds, etc.)? I’d like a way to
upload and delete them from a browser, again to avoid Subversion and
deployment hassles. It looks like the Gallery extension might work
for this. Any other recommendations?


Tim Jones
Barbary Codes and Data


Chris P., with whom I’ve spoken privately, is working on an
extension that will allow you to manage CSS and JavaScript separate from
the page sitemap and have them be cached in some reasonable place so
they can be served by your web server. In the meantime, you can create
pages in the sitemap that have special layouts that specify their
content type. It means an extra hit to Radiant to get the CSS or JS, but
it’s a good interim solution.

To accomplish this, I would create a child of the homepage called
“Stylesheets”, and create a layout for it like this:

Name: CSS
Content type: text/css
Content: <r:content />

Then create child pages of “Stylesheets” that are your individual
stylesheets, modifying the slug to end in “.css” if you desire.

You can do the same for JS.



Sean, you’re too fast…

Well Timothy, you’re in luck. At John’s request, I have put together an
extension to manage CSS & JS files as assets separate from normal
pages. I’ve got a little rearranging that he’s asked for before I
release it into the wild. Look for an announcement here soon - probably
by this weekend.

In the meantime, Sean’s explanation saved me some time explaining it
here and works well enough for how (though we’ve all felt it a little
hack-ish – hence the new solution).

As to other assets, Sean has a very well used PageAttachments extension,
Andrea F. has a Gallery extension and Keith B. also has an
Assets extension (though he’ll be the first to tell you it’s not
production ready right now). Links and info on these third party
extensions can be found here:


I’ve just got onto using radiant last week, it’s been great to get up
to speed fast and be able to slam out some sites that have been

While I’ve been able to install some extensions like shard fine others
won’t load when I issue:
rake db:dbmigrate:extensions

I receive the following error:

Could not load extension from file: meta_data_extension.
#<NameError: uninitialized constant MetaDataExtension>

Which I’m unsure of how to resolve.

thanks in advance

Brian Loomis
Brian Loomis
[email protected]
(208) 562-3944

Make sure that the directory containing the extension is named the same
as the *_extension.rb file inside it. If it’s metadata_extension.rb,
name the directory metadata, etc.


I did change the extension folder name to match the .rb file then ran
the command again with this error:

Could not load extension from file: page_meta_extension_extension.
#<NameError: uninitialized constant PageMetaExtensionExtension>

Am I to load extensions in to the extensions folder at the root of
site or the entensions folder in vendors where the three that radiant
comes with are located/

shards loaded and worked from the root extension folder but page_meta
data will not.

On Feb 20, 2008, at 2:48 PM, Sean C. wrote:


Radiant mailing list
Brian Loomis
[email protected]
(208) 562-3944

Sounds good, Chris - also looking forward to this one, just what I
need :slight_smile:

You are having the same problem still. Don’t use _extension on the
directory name.