# External javascripts, stylesheets, etc

**URL:** <https://www.ruby-forum.com/t/external-javascripts-stylesheets-etc/65176>\
**Category:** Radiant CMS\
**Created:** [August 16, 2006, 5:29pm UTC](https://www.ruby-forum.com/t/external-javascripts-stylesheets-etc/65176 "2006-08-16T17:29:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [August 16, 2006, 5:29pm UTC](https://www.ruby-forum.com/t/external-javascripts-stylesheets-etc/65176/1 "2006-08-16T17:29:50Z")

</div>

Hi, folks. I have another question which I realize must be painfully  
obvious to most of you. I’m still confused about a few things.

On the default radiant layout. Within the admin, on the ‘Pages’ tab  
there is a page called ‘styles’ which contains all the css for the  
site. This ‘styles’ page has a layout option called stylesheet. When  
I go to the layouts tab there is a layout named ‘stylesheets’ that  
only contains \<r:content /\>

What is the process? Does radiant automatically create the css from  
the ‘page’ file and stick it in the public/stylesheets directory? Or  
does it embed them into the outputted xhtml?

If I create a ‘layout’ named “javascripts” and then I create a  
‘page’ with javascript in it and the layout option ‘javascripts’ will  
radiant automatically create my javascript file and place it in the  
javascripts folder?

My goal is to have all javascript and css external from the xhtml.  
Would I be better off just creating my own ‘css’ & ‘scripts’ folders  
within the public directory and just referencing them from snippets  
and layouts as I would with images?

thanks,  
mike

---

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [August 16, 2006, 5:38pm UTC](https://www.ruby-forum.com/t/external-javascripts-stylesheets-etc/65176/2 "2006-08-16T17:38:51Z")

</div>

Mike,

Not exactly. Another layout or page would need to refer to the Radiant  
page  
(CSS, Javascript) by its URL for it to be used.

The real reason they need a layout is to set the content-type. Other  
than  
that, it makes good sense to just dump the content of the page when it’s  
CSS  
or Javascript, unless you’re doing something programmatic (i.e. Radius  
tags)  
in them.

So, to create your own text-based assets in Radiant, you would simply  
enter  
the content of the file, assign it the Stylesheet or Javascript layout  
template, take note of the “slug” (click “more” near the title) and  
construct the appropriate URL to the asset based on its slug, parent  
slugs  
and root URL path of your application. Then you can use that path/URL  
in  
your layouts, snippets, or other pages.

Hope this helps!

Sean C.  
[seancribbs.com](http://seancribbs.com)

---

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [August 17, 2006, 4:04am UTC](https://www.ruby-forum.com/t/external-javascripts-stylesheets-etc/65176/3 "2006-08-17T04:04:27Z")

</div>

Just to add a bit to Sean’s reply:

On 17/08/2006, at 12:27 AM, Michael M. wrote:

> My goal is to have all javascript and css external from the xhtml.  
> Would I be better off just creating my own ‘css’ & ‘scripts’ folders  
> within the public directory and just referencing them from snippets  
> and layouts as I would with images?

It depends how you work with your CSS and scripts. If you want to be  
able to edit them online in the same way you edit your page content,  
then stick them in Radiant. If, like me, you prefer to edit scripts in  
a “real” editor (not in a browser textarea) then I’d say put them in  
your public directory.

Bodhi
