What is Correct Way to Include CSS File?

What is the correct way include a css file in an app?

I created a custom app. I installed it to the site and its definitely loaded because it shows in the About Dialog.

  1. I put my css file in app_name/public/css/my_css.css

  2. I added it to the corresponding css line in hooks.py:
    app_include_css = “/assets/app_name/css/my_css.css”

When I reload the erpnext desk and look at the source code, I don’t see any indication that my_css.css is actually loading anywhere.

Am I missing something?

I looked at the Asset Bundling stuff in the Frappe Documentation. That stuff seems more complicated. I tried it anyway and I couldn’t get it to work either.

1 Like

If you’re not seeing any indication of the CSS file (nor even a 404 message in your console’s network tab), it’s likely a caching issue. Is your server setup for development (bench start) or production (nginx reverse proxy and supervisor)?

And don’t forget to run bench build --app appname or just bench build for all apps.

1 Like

@rahy Thank you!
I wasn’t aware of the importance of using bench build to target specific app. I think this fixed my problem. The CSS file shows up in the Desk page source now.

1 Like