Skip to content
Advertisement

Laravel edit page does not call CSS and JS when on a server

I made an edit page for my application which is accessible via the index. I have a master.blade.php file that contains all the references for scripting and the CSS links. and every page calls this master page to make use of the Nav bar, heading and the CSS/JS. The edit page does not seem to call this and on the console it shows 404 not found for these CSS and JS files when I pushed this project on a server. Does anyone know what I am doing wrong

I have changed the routing of the CSS/JS files to route correctly and that calls correctly everywhere else but this page.

Here is a sample of my paths:

<link href="../assets/css/bootstrap.min.css" rel="stylesheet" />

this is in my master page, so in my other pages I call:

@extends('layouts.master')

Advertisement

Answer

In Laravel, best way to import any asset, is using asset function in your blade file:

asset('path to css')

This is work for images, CSS and JS files, and other files to import into a blade or HTML. just upload your files into “public” folder like this folders scaffolding:

---- public
---- ---- css
---- ---- ---- bootstrap.min.css

and use asset function like this:

<link href="{{asset('css/bootstrap.min.css')}}" rel="stylesheet" />

I hope this response being useful for you!

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement