Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 Twig template - css not loading

Tags:

css

twig

symfony

I have imported the client side of my web app to

/bundle/Resources/views

This includes html documents, as well as the css, js, images and fonts folders. When i open an html page in a browser, it renders fine. But just by changing the extension of the file to .html.twig and rendering it through the symfony2 framework disables css.

I have also copied the css, js, images and font folders to

/bundle/Resources/public

I have also tried using the twig assets('') function with no luck.

What's going on?

like image 265
Mihai Raulea Avatar asked Jan 26 '26 19:01

Mihai Raulea


1 Answers

First execute app/console assets:install ( consider adding --symlink ). The command will copy/symlink all your bundle's Resources/public to web/bundles and create a folder in there named as the lowercase bundle-name without a trailing "Bundle".

example:

YourAwesomeBundle\Resources\public\css\style.css will be copied/symlinked to web\bundles\yourawesome\css\style.css

... afterwards include the assets using asset("@YourBundle/Resources/public/css/style.css")

... or asset("bundles/your/css/style.css")

like image 128
Nicolai Fröhlich Avatar answered Jan 28 '26 09:01

Nicolai Fröhlich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!