cssexpressreferencehandlebars.jsworkspace

css files not load express-handlebars


I'm having trouble with the CSS acess using express-handlebars. I can't see the problem and I would like to have your help.

Here is my Workspace: Workspace/Meus Arquivos

In my home.handlebars: <link rel="stylesheet" href= "css/home.css">

In my home.css:

footer{ background-color: blue; }

Instead of showing a blue background as I ask for, it shows nothing:

Footer code:

    <footer>
    <font size = 4>
        <h5>© 2019 Suplementos Atlética</h5>
    </font>
</footer>

Footer/Rodapé


Solution

  • In expresss, you have to set express static. It Will looks like this code below:

    app.use(express.static('public'));
    

    if your public folder is inside src folder use below method

    app.use(express.static("src/public"));
    

    Now, you can create a public folder in your root app and css folder in your public folder and put your style into there.

    So, your directory with looks like this:

    How to use? You can call your link like this:

    <link rel="stylesheet" href= "/css/home.css">
    

    For an example, you can look at my example project here: https://codesandbox.io/s/elegant-fog-1n61o