Looking for some help here regarding adding styles and scripts(.css, and .js files) to a header on my page.

I know that i have to be on developer mode to do this but i don't know where i have to put my files, this is what i have done so far:

i have added it to my file tree here is the file paths....


Am i doing anything wrong?

Please advise. Looking forward to your reply as i can't find it in my header of my page.

I have total 7 files 2 .css and 5 .js files and one default head blocks under layout (this is where i added in the src, and href to)

I think this is wrong?

Please keep in mind that i am using Magento2 via AWS Lightsail and Lightsail ssh, along with AWS cloud 9 for file tree(as path may be different) also please note that i created a new topic due to none existing with Lightsail path

Thank you.


Magento 2 uses RequireJS to load .js files within your project. You can find the requirejs-config.js file in the root of your theme.

See following link for more: Add custom Javascript using RequireJs

Also, I advise you not to edit any core files. The cleanest approach would be creating your own theme, for example copying the Luma theme and editing it to your own likes.

The way of including .css within your project is right, you include this in your default_head_blocks.xml in Magento-Theme

  • thank you for your help Bramulous, i still have not figured it out. Also to Jai , ManojDeswal , ManashviBirla , Piyush , Priyank note this is not a duplicate as the CLI for magento via aws lightsail path is different please provide me the link to the duplicate with a adding .css and .js for magento via aws lightsail. Mar 28 '18 at 4:27
  • Could you be more specific about what you can't figure out? What is the first thing you are trying to accomplish?
    – Condor
    Mar 28 '18 at 6:01
  • hey @bramuious I am trying to add style sheet to my website i have 7 files in total 2 of them are .css, and the other 5 are .js files. so far i have attached them to my file tree as explained above in the question. now that it has been added (not sure in the correct place) i see it in my page and also i don't see it when i view page source Mar 28 '18 at 6:47
  • Are you using a custom theme? If yes, do you have a requirejs-config.js file in your root directory of the custom theme?
    – Condor
    Mar 28 '18 at 6:51
  • hey, no i am not using a custom theme... is that what i should do 1st? is so, how would i do that? thank you. Mar 28 '18 at 6:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.