I have my stylesheets linked in my header as
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/meanmenu.min.css">
I'm using the MEAN stack in AWS Cloud9 Development Environment, and when I preview my application, everything is styled exactly how I plan using these stylesheets as they're in my public directory, but when I add any backslash into the end of my URL path in preview the stylesheets are not linking. For example, stylesheets are clearly linked on mysite.com/test, but mysite.com/test/ or mysite.com/test/example seems to unlink and everything is in standard raw HTML format. If I link the CDN they work, but I need to link custom stylesheets as well.
I have
app.use(express.static(__dirname + "/public"));
to tell the browser where to search.
Thanks
If you go to the next level after test (eg: mysite.com/test/example), you need to go up a level, since paths are relative.
Try:
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" href="../css/font-awesome.min.css">
<link rel="stylesheet" href="../css/owl.carousel.min.css">
<link rel="stylesheet" href="../css/animate.css">
<link rel="stylesheet" href="../css/meanmenu.min.css">
Now, hardcoding your paths might get annoying after a while; you might want to provide these paths as part of your locals.
Related
I'm working in Django 1.8, OSX, and Chrome. Some ionicons I've included in a rendered template are not showing up in Heroku (staging environment). I'm fairly certain that I have linked/included the icons properly in the css and font files (30464569), because they show up just fine on the localhost, on cPanel, and when published on the person's own website. Additionally, they even show up on Heroku if I use Safari! What is happening here?
I've read a bunch of SO posts about this, but most people are referencing other font packages (29687388) or (14366158), other frameworks (25982037) or (21472458), or completely missing icons (27766015).
EDITED TO INCLUDE HTML (from Django template)
<head>
<meta charset="UTF-8">
<title>{{ student.preferred_name }} {{ student.last_name }}</title>
<!--<meta name="description" content="[Insert your description here]">-->
<!--<meta name="google-site-verification" content="">-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{% asset 'vendors/css/normalize.css' %}">
<link rel="stylesheet" type="text/css" href="{% asset 'vendors/css/grid.css' %}">
<link rel="stylesheet" type="text/css" href="{% asset 'vendors/css/owl.carousel.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% asset 'vendors/css/owl.theme.default.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% asset 'vendors/css/ionicons.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% asset 'resources/css/queries.css' %}">
<link rel="stylesheet" type="text/css" href="{% asset 'resources/css/style.css' %}">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Lato:400,100,300,300italic">
</head>
I'm hesitant to post code because it's not a public project, but here are are two images showing the issue:
Icons on LocalHost
Icons on Heroku
Any ideas on how I can fix this? I need my users to see an accurate preview before they publish their site and this icon issue has been a major headache for over a week.
Thanks!
Sarah
Be sure that run command $python manage.py collectstatic before pushing to heroku.
I had this same problem
confirm that the static assets are correctly spelled
Note that it might not be case sensitive on windows but Linus is case sensitive and Heroku runs on Linus
so ensure that your lower and upper cases are in place
I have a large php application that I am converting to ember.js. In my php application I used to have separate css and js files which was loaded when the specific routes get called. what the best way to accomplish this in ember.js or is there any other best practice for that. Right now I am loading all the js and css files in my index.html file.
<link type="text/css" rel="stylesheet" href="assets/css/gumby.css" media="all" />
<link type="text/css" rel="stylesheet" href="assets/css/pages/global.css" media="all" />
<link type="text/css" rel="stylesheet" href=assets/css/tooltipster.css" media="screen" />
<link type="text/css" rel="stylesheet" href="assets/css/jquery.fancybox.css" media="screen" />
<link type="text/css" rel="stylesheet" href="assets/css/pages/about.css" media="screen" />
<link type="text/css" rel="stylesheet" href="assets/css/pages/admin.css" media="screen" />
<link type="text/css" rel="stylesheet" href="assets/css/pages/global_print.css" media="print" />
js files:
<script src="assets/js/libs/jquery-1.9.0.min.js"></script>
<script src="js/libs/handlebars-1.1.2.js"></script>
<script src="js/libs/ember-1.6.1.js"></script>
<script src="js/libs/ember-data.js"></script>
<script src="js/app.js"></script>
<script src="js/router.js"></script>
<script src="js/account.js"></script>
<script src="js/message.js"></script>
<script src="js/user.js"></script>
<script src="js/inquiry.js"></script>
I saw this tutorial http://madhatted.com/2013/6/29/lazy-loading-with-ember and also looked ember-cli. It will be really helpful for me if people share what they are doing for their application. Thanks in advance.
Typically you can take two paths to preprocess your assets: minify, compress, uglify, etc.
You can do it with the back-end you are using. As examples here, you have Rails using sprockets for its asset pipeline, or PHP's Assetic.
If you don't want to rely on your back-end for this task, you can opt to do it using any front-end build tool. There are a few here, the most popular option for ember-cli these days seems to be broccoli, which comes set up by default. Other choices could be gulp or grunt. All these options involve using your terminal to build your application, using a configuration file as a central point (Brocfile.js, Gruntfile.js, etc.)
It's mostly a matter of personal preference. As an example, I'd probably go with Rails asset pipeline for small projects, while I'd use ember-cli and broccoli if I'd be working on something bigger.
I am new to Django and am trying to learn how to serve static files in local deployment. I have read this and many other possible related problems from stackoverflow but i cant seem to be able to find solve my problem.
This is my settings , I cant figure out what is the reason Django isnt serving my static files
STATIC_ROOT = ''
STATIC_URL = '/html/'
STATICFILES_DIRS=('C:/Users/RayLim/Desktop/project/home/username/djcode/mysite/mysite/templates/html',)
In my templates I refer to them as
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
The structure of my html file which is located at C:/Users/RayLim/Desktop/project/home/username/djcode/mysite/mysite/templates
html
/css
/images
/style.css
/js
/jquery.jcarousel.pack
/jquery-1.4.1.min
/jquery-func
This is the server response
"GET /home/css/images/big1.jpg HTTP 1.1" 404 3782
First, static files and templates are usually in separate directories but I don't think there would be any problem (that I'm aware of...)
Next, you want to make sure that you use a template tag to represent the static file location instead of using css/.. which expects there to be a css directory relative to whatever url you are currently viewing.
There are a couple template tags you can use, I use {{ STATIC_URL }}
So replace
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
with
<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css" type="text/css" media="all" />
And you should be all set...
You should avoid hard linking to your static directories. It can cause confusion and potential problems as your project gets bigger
Please refer to this, it has everything you need.
Django staticfiles app help
Hey can any one tell me about how to link print version CSS?? I have created a head and linked the head file as
< link media="print" type="text/css" rel="stylesheet"
href="#request.subsiteCache[1].url#style/print.css">
but I'm unable to get the exact style version for the print as I have mentioned in print.css
Do I need to do anything more apart from this?
I'm using commonspot.
I wrapped it in cfoutput tags
did you wrap your link tag around cfoutput?
<cfoutput>
<link media="print" type="text/css" rel="stylesheet" href="#request.subsiteCache[1].url#style/print.css">
</cfoutput>
I'm using django 1.3
I'm using a base.html template which my pages inherit from. Everything works fine except for one page (which has a form on it).
That page is trying to call the CSS from /links/addlink/css/site.css but this is the wrong location. It is in /static/css/site.css
In my base.html I have <link rel="stylesheet" href="{{ STATIC_URL }}css/site.css" type="text/css" charset="utf-8" />
If I create a completely seperate template and use the full path like <link rel="stylesheet" href="http://127.0.0.1:8000/static/css/site.css" type="text/css" charset="utf-8" /> then my page renders correctly.
What is wrong?
You are not using RequestContextin your view.
See here: Referring to static files in templates