In my source code of Blade file of CSS include URL is like below
<link rel="stylesheet" href="{{ asset('frontend/css/bootstrap.min.css') }}" type="text/css">
But I am getting below URL in page source of browser
<link rel="stylesheet" href="http://127.0.0.1:8000/public/frontend/css/bootstrap.min.css" type="text/css">
Why I am getting this ? How can I remove public from the URL ?
You're getting public in the path because you're accessing your site the same way http://127.0.0.1:8000/public/.
You need to change how your server serves the application.
asset() function points to the public folder. For your css file to work make a 'frontend' folder in the public directory
Related
I have a spring boot application that contains static resources in the structure indicated below ( + indicates directories, - indicates files)
+ my-app
+ src
+ resources
+ static
+ v1
+ css
- app.css
- main.js
- index.html
I have sub-directory that contains the application bundles. By default, Spring looks for index.html directly under resources/static directory. It does not find one in this case.
My index.html looks something like this
<html>
<head>
<script type="text/javascript" src="main.js"></script>
<link type="text/css" href="css/app.css"/>
</head>
<body>
</body>
</html>
Let us assume the application is hosted at http://myapp.com.
I have two questions here
How can I make Spring to look for v1/index.html under my static resources, when I access the application the URL http://myapp.com?
If I load v1/index.htmlby adding a view controller in ViewControllerRegistry, it does load index.html under v1 directory, but gives 404 on all the resources used by index.html (main.js & css/app.css).
How can I tell Spring to get all resources from resources/static/v1, instead of resources/static.
I created a basic Spring Boot Project in STS and did not any dependencies. I used your html sample from above and modified it to this:
<html>
<head>
<script type="text/javascript" src="main.js"></script>
<link rel="stylesheet" type="text/css" href="/v1/css/app.css"/>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
I created the directory /src/resources/static/v1 and /src/resources/static/v1/css, placing the index.html file in the ../v1 directory which worked. The app.css file contained the following for testing purposes:
h1 {
color:red;
}
This worked without any configuration changes to Spring. If you are using Thymeleaf, JTwig, JSP... you may need to add resource handlers or tweak settings for those template engines, I can't comment since I didn't use a template engine based on your example. Anything in the /static directory will be referenced without the /static.
I hope that helps, if it does please mark the answer as the right answer.
I uploaded my SF Application from my local (machine) to production (Cpanel server)
everything looks fine on production except the css, js, etc. (All files inside the web directory.
I open the var/logs/prod.log just to check whats happening and I find out these errors.
request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /stylesheets/base.css" (from "http://example.com/admin/login")" etc.........
Now, what I did is to open the base.html.twig and made changes on the path of css/js files.
From
<link href="{{ asset('stylesheets/base.css') }}" rel="stylesheet" />
To the full directory.
<link href="{{ asset('/home2/swipecom/public_html/web/stylesheets/base.css') }}" rel="stylesheet" />
By the way, here's the directory of the application in the server.
home/swipecom
cache
contactless (Where SF directories live)
- public_html (/web the only SF directory)
var
ssl
tmp
public_ftp
logs
I made it work using this code
<link href="{{ asset('web/stylesheets/base.css') }}" rel="stylesheet" />
I'm having a strange issue in my Laravel 5.2 app. Specifically with loading some CSS and JavaScript files. I have this in the folder public/assets so, I have something like this:
|--public
|----/assets
|-------/css
|------------/auth
|---------------login.css
|----------main.css
|-------/js
|---------email.js
|---------/modules
|------------faq.js
That is my directory, so I'm loading the CSS with:
<link href="{{ URL::asset('assets/css/main.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ URL::asset('assets/css/auth/login.css') }}" rel="stylesheet" type="text/css" />
And the JavaScript files with:
<script src="{{ asset('assets/js/email.js') }}" type="text/javascript"></script>
<script src="{{ asset('assets/js/modules/faq.js') }}" type="text/javascript"></script>
Also I'm loading another files as well but I'm explaining the basic situation. So, the thing is that the load of login.css and faq.js are giving me 404 error but the other files are loaded correctly, I even checked open the files through the absolute paths and they're loaded fine, also I made chown to www-data of the public folder but nothing works, so I don't know why a 404 error is triggered. What else should I check?
In the console of the browser the links that are loaded are:
http://mydomain/assets/js/modules/faq.js
http://mydomain/assets/css/auth/login.css
But they give 404 error, and the other files doesn't
first check those 404 files are in there definitely
check those files have readable permisstion
I am trying to set up a website using Jekyll and GitHub Pages (first-timer), and most importantly, to style it with Bootstrap.
You can check what I have already done:
GitHub repository: https://github.com/thibaudclement/wallaby
GitHub page: http://thibaudclement.github.io/wallaby/ (check gh-pages branch)
Also, I followed this tutorial to import Bootstrap into the Jekyll structure.
Layouts and includes seem to work just fine, but I don't understand why my index.html does not get "styled" as it should, fetching information into the css/style.css file.
Any idea of what I am doing wrong?
Thanks.
The path to your css file is incorrect - it's not loading if you check your browser console
"Failed to load resource: the server responded with a status of 404 (Not Found) - http://thibaudclement.github.io/wallaby/style/site.css"
In _config.yml, you need to set baseurl: /wallaby.
And use {{ site.baseurl }} to load resources like this :
<link href="{{ site.baseurl }}/css/style.css" media="screen" rel="stylesheet" type="text/css" />.
See Jekyll documentation.
CSS link:
<link rel="stylesheet" href="/site_media/style.css"
type="/text/css" />
I'm getting a -404 error while loading my CSS sheet.When I try to debug the location thru Firebug(Firefox), I get the below location.
"C:\Python27\Djangoprojects\django_bookmarks..\django_bookmarks\site_media\style.css" does not exist
Site_media is determined by the Python code in URLS.py
site_media = os.path.join(os.path.dirname(__file__), 'site_media')
Why do I get the ..\ in the location?