cancel
Showing results for 
Search instead for 
Did you mean: 

Adding css and js files to page

Adding css and js files to page

I have been trying to do this for about a week now, and for some reason I can't get it to work. I've tried Google, but it's very difficult to find.

 

What I'm trying to do is very simple. I want to add css and js files to the homepage. Doing this via the admin panel under CMS -> Pages -> Design -> HomePage in the Custom Layout Update XML is quite easy and works as expected. However, I would like to do this from layout xml files. I have tried a layout.xml file in app/design/frontend/{package_name}/{theme_name}, but this file doesn't seem to get loaded from the homepage, as introducing a formatting error to layout.xml does not trigger an error on the frontpage.

 

Could someone please tell me step-by-step what I need to do to get a js file to show up on the frontpage ?

3 REPLIES

Re: Adding css and js files to page


handyCAPS wrote:
I have tried a layout.xml file in app/design/frontend/{package_name}/{theme_name}, but this file doesn't seem to get loaded from the homepage, as introducing a formatting error to layout.xml does not trigger an error on the frontpage.

Rename from layout.xml to local.xml. Any local layout modifications belong in a file called local.xml in your custom theme app/design/frontend/{package_name}/{theme_name}/layout folder.

Re: Adding css and js files to page

Thank you for your answer. Reading back I did sound very frustated.

 

I figured out what went wrong, turns out under CMS -> Pages -> Home Page -> Design I had set a custom theme and forgot all about it. I feel a bit stupid now, I guess Magento has that effect on people.

Re: Adding css and js files to page

Magic and Mages have that effect on people. Magento is the current day sorcerer we'd all love to banish to one of the circles of Dante's Inferno from time to time.