Updated CSS Stylesheet Not Loaded Following Deployment to Heroku

Updated CSS Stylesheet not loaded following deployment to Heroku?

It looks like you have added assets precompiled file in your git repo. Ideally, it shouldn't be there since heroku can do this for you whenever you push it.

To fix this, you have to do this

  1. git rm -r public/assets/
  2. add public/assets/** in your .gitignore file
  3. git add .
  4. git commit -am "allow heroku auto assets precompilation"
  5. git push heroku master

Heroku CSS file not updating

I was having the same problem with Django on heroku. After following the standard git add, commit, push loop - the server's CSS was not updating. Everything, including static files, had been pushed to the server.

Restarting the heroku server worked though:

heroku restart

Give that a go!

Why my css file is not loading when deployed in heroku? P.S: I'm using ejs

After rigorous research and trying so many ways finally I'm able to resolve my issue by myself.

I have done some major changes, and my issue was resolved.

  • I have changed my file structure a little bit.

  • From this to this

  • I have created a new directory called partials in the views directory and moved my header.ejs and footer.ejs files to that directory.

  • In header.ejs file I have changed the code from this


  • <link href="css/styles.css" rel="stylesheet" type="text/css" >

    to

    <link href="/css/styles.css" rel="stylesheet" type="text/css" >
  • In other .ejs files I have included the header.ejs and footer.ejs as follows:

    <%- include("partials/header"); -%>
    <%- include("partials/footer"); -%>

And that's how I am able to solve my issue.

Hakuna Matata

css stylesheet not applied when it is deployed in heroku.but works in localhost node.js

Your public folder is named "Public" while you're passing public (with lowercase p) to express.static(). Rename your folder to exactly match the code and try again.

Removed Stylesheet from application but it still appears on Heroku

You will have to do a couple of more steps:

$ rake assets:precompile
$ git add .
$ git commit
... deploy to heroku

rake assets:clean just removes the compiled assets locally; without running the precompile step to generate new assets, the assets on heroku does not get refreshed.



Related Topics



Leave a reply



Submit