0

I'm doing a little website for me with Laravel 8.0.

Inside home.blade.php, I have this : <link rel="stylesheet" href="{{ asset('css/header.css') }}"> But when I go to my browser, no css in my page. Inside the developper tools, it says <link rel="stylesheet" href="http://localhost/css/header_site.css">.

I have all my css inside the public/assets/css folder.

I also used the VirtualHost inside httpd-vhosts.conf where I do DocumentRoot "C:/xampp/htdocs/my-project/public".

Cordially

7
  • try with href="{{ asset('assets/css/header.css') Commented Jan 10, 2021 at 16:08
  • Still not working. I also tried with URL:: and also with public/assets/css/header.css What trigger me is that when I go to the developper tools, there path is http://localhost/css/header_site.css and that's wrong. Commented Jan 10, 2021 at 16:10
  • give the full url for testing purposes. http://localhost/assets/css/header_site.css Also see if this url produces the css file in the browser. Commented Jan 10, 2021 at 16:13
  • Also, by public/asset.. you mean in the public folder right? Not the storage/public/assets? Coz, if it's storage make sure you have established the symlink. Commented Jan 10, 2021 at 16:15
  • 1
    Well then, why dont you try configuring the assets url in the .env file. ASSET_URL=http://localhost/assets/. Then do {{asset('css/header.css')}}. See if it changes anything, Commented Jan 10, 2021 at 16:22

2 Answers 2

1

Try configuring the assets url in the .env file. ASSET_URL=http://localhost/assets/. Then do {{asset('css/header.css')}}

Sign up to request clarification or add additional context in comments.

Comments

0

I had a similar issue but it was after I had deployed the application to a hosted service. The stylings were not showing.

I checked the network tab on the hosted link and my CSS stylings were blocked they were rendering through http:// my base URL and not https://

Adding this to my app/Providers/AppServiceProvider.php fixed it for me

public function boot()
{
    //
    if (config('app.env') !== 'local') {
        URL::forceScheme('https');
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.