<p>For static assets I usually use something like this:</p>

<pre><code>{% if craft.debugMode %}
    {% set assetsUrl = siteUrl %}
{% else %}
    {% set assetsUrl = "assets.mysite.com" %}
{% endif %}
</code></pre>

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

<pre><code>{% includeJsFile assetsUrl ~ "js/init.js" %}

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

}
{% endincludecss %}
</code></pre>

CC BY-SA 3.0
2015-08-13T05:23:08.887Z
2015-08-13T11:26:38.260Z
2015-08-13T11:26:38.260Z
j00lz
<p>i just started using craft on a local domain and i have some issues.
my stylesheet(a few files) are loaded using html<code>&lt;link rel="stylesheet" href="style/style.css"&gt;</code>, 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.</p>

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

<p>Thanks Ahead!</p>

CC BY-SA 3.0
2015-07-25T20:26:37.487Z
Have you tried using root relative paths?  `/style/style.css` instead of `style/style.css`?
Steve Adams
CC BY-SA 3.0
2015-07-25T23:05:28.840Z
yes, iv'e tried
Samuel E.
CC BY-SA 3.0
2015-07-25T23:19:35.073Z
How about in the CSS file itself?  What do your `selector: url(path);` look like?
Steve Adams
CC BY-SA 3.0
2015-07-26T09:56:28.007Z
its relarive: url(url/to/some/path);
Samuel E.
CC BY-SA 3.0
2015-07-27T02:11:54.297Z
https://yoast.com/relative-urls-issues/
Steve Adams
<css>
Issues loading files from within css files
# Issues loading files from within css files

(Asked by: username_0 on 2015-07-25)

i just started using craft on a local domain and i have some issues.
my stylesheet(a few files) are loaded using html, 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!

**Tags:** css

> **Comments:**
> **username_1**: Have you tried using root relative paths?  `/style/style.css` instead of `style/style.css`?  
> **username_0**: yes, iv'e tried  
> **username_1**: How about in the CSS file itself?  What do your `selector: url(path);` look like?  
> **username_0**: its relarive: url(url/to/some/path);  
> **username_1**: https://yoast.com/relative-urls-issues/  

---

## 1 answers

### Answer by username_2 on 2015-08-13. Score: 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 %}


---

