1

i just started using craft on a local domain and i have some issues. my stylesheet(a few files) are loaded using html<link rel="stylesheet" href="style/style.css">, and it works great for css and js files, but files requested from within the css aren't loading. for example the Font Awesome @fontface.

Any ideas? and the is any issue using html instead of the {{ getHeadHtml() }} method?

Thanks Ahead!

5
  • 3
    Have you tried using root relative paths? /style/style.css instead of style/style.css? Commented Jul 25, 2015 at 20:26
  • yes, iv'e tried
    – Samuel E.
    Commented Jul 25, 2015 at 23:05
  • 1
    How about in the CSS file itself? What do your selector: url(path); look like? Commented Jul 25, 2015 at 23:19
  • its relarive: url(url/to/some/path);
    – Samuel E.
    Commented Jul 26, 2015 at 9:56
  • yoast.com/relative-urls-issues Commented Jul 27, 2015 at 2:11

1 Answer 1

1

For static assets I usually use something like this:

{% if craft.debugMode %}
    {% set assetsUrl = siteUrl %}
{% else %}
    {% set assetsUrl = "assets.mysite.com" %}
{% endif %}

And then I can set assets URL's the same way as navigation URLs. ie.

{% includeJsFile assetsUrl ~ "js/init.js" %}

{% includecss %}
body.landing #page-wrapper {
    background-image: url(" {{ assetsUrl }}img/pic01.jpg  }}");

}
{% endincludecss %}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.