Answers.Body: <p>You need to make the url absolute, or relative to the root. The url() function will help you to keep this maintainable. </p>
  
  <pre><code>{{ url('assets/build/css/main.css') }}
  </code></pre>
  
  <p>This will prepend the {{ siteUrl }} to the path, so if you move the site later, or are running in a multi environment setup, the path will be updated. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T09:49:20.240Z
Answers.Text: A word of warning about `url()`: it is subject to whether Craft thinks the server supports index.php redirecting, even if you're only pointing it to a static file. So only use it with static file URLs if you've set the [omitScriptNameInUrls](http://buildwithcraft.com/docs/config-settings#omitScriptNameInUrls) config setting to `true`.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T07:40:14.610Z
Answers.LastActivityDate: 2014-06-26T07:40:14.610Z
Answers.UserDisplayName: André Elvan
Answers.Body: <p>The links aren't working because that's a relative URL, from whatever the last "directory"-looking segment in your page's URL is.</p>
  
  <p>To resolve this, you can either make your URLs root-relative:</p>
  
  <pre><code>&lt;link href="/css/myStylesheet.css" rel="stylesheet"&gt;
  </code></pre>
  
  <p>Or relative to the site URL:</p>
  
  <pre><code>&lt;link href="{{ siteUrl }}css/myStylesheet.css" rel="stylesheet"&gt;
  </code></pre>
  
  <p>The drawback to root-relative URLs is, it makes your site a little less portable - you'll only be able to install the site in a web root (no subfolders) without having to update all URLs.</p>
  
  <p>If this is a localized site with multiple site URLs, then both solutions could have issues. In that case it might make sense to define your own custom config setting in craft/config/general.php:</p>
  
  <pre><code>'baseResourceUrl' =&gt; "http://example.com/",
  </code></pre>
  
  <p>Then call glad from your templates instead of <code>siteUrl</code>:</p>
  
  <pre><code>&lt;link href="{{ craft.config.baseResourceUrl }}css/myStylesheet.css" rel="stylesheet"&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T10:42:50.647Z
Answers.Text: Thanks for adding the config settings for localized sites, Brandon. Wasn't quite sure if I encountered problems because me redefining `siteUrl` with `define('CRAFT_SITE_URL', '{siteUrl}en/');` in `en/index.php`. Additional question: is the "new" technique to set `siteUrl` with an array `'siteUrl' => array('de' => 'http://example.com/', 'en' => 'http://example.com/en/')` preferable?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T18:11:47.890Z
Answers.Text: Thanks Brandon. I thought of the 'baseResourceUrl' option but thought there might be a simpler solution.
Answers.UserDisplayName: blairrorani
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T19:19:30.877Z
Answers.Text: @ChristianSeelbach Yes the new [siteUrl](http://buildwithcraft.com/docs/config-settings#siteUrl) config setting is a better way to define locale-specific URLs than defining CRAFT_SITE_URL constants. With the config setting, Craft will know what an entry’s URL is in all locales, so “Share” links will always be correct, for example.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-27T17:35:50.123Z
Answers.Text: @BrandonKelly Not to be a jerk, but there's a typo (`baseReaourceUrl`) in the third code block I can't edit. People like me copy those things and become confused later.
Answers.UserDisplayName: Matt Stein
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T09:59:04.327Z
Answers.LastActivityDate: 2016-01-28T20:10:39.613Z
Answers.LastEditDate: 2016-01-28T20:10:39.613Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>When I navigate to [home]/news/2014/poster my relative links to stylesheets break. I am using:</p>
  
  <pre><code>&lt;link href="css/myStylesheet.css" rel="stylesheet"&gt;
  </code></pre>
  
  <p>How do I stop these links breaking in this scenario?</p>
  
Tags: <templating>
Title: How do I stop my relative links to stylesheets breaking?
ThreadText: # How do I stop my relative links to stylesheets breaking?
  
  (Asked by: username_0 on 2014-06-26)
  
  When I navigate to [home]/news/2014/poster my relative links to stylesheets break. I am using:
  
  ```
  <link href="css/myStylesheet.css" rel="stylesheet">
  
  ```
  
  How do I stop these links breaking in this scenario?
  
  **Tags:** templating
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2014-06-26. Score: 11 | Accepted answer
  
  The links aren't working because that's a relative URL, from whatever the last "directory"-looking segment in your page's URL is.
  
  To resolve this, you can either make your URLs root-relative:
  
  ```
  <link href="/css/myStylesheet.css" rel="stylesheet">
  
  ```
  
  Or relative to the site URL:
  
  ```
  <link href="{{ siteUrl }}css/myStylesheet.css" rel="stylesheet">
  
  ```
  
  The drawback to root-relative URLs is, it makes your site a little less portable - you'll only be able to install the site in a web root (no subfolders) without having to update all URLs.
  
  If this is a localized site with multiple site URLs, then both solutions could have issues. In that case it might make sense to define your own custom config setting in craft/config/general.php:
  
  ```
  'baseResourceUrl' => "http://example.com/",
  
  ```
  
  Then call glad from your templates instead of `siteUrl`:
  
  ```
  <link href="{{ craft.config.baseResourceUrl }}css/myStylesheet.css" rel="stylesheet">
  
  ```
  
  > **Comments:**
  > **username_3**: Thanks for adding the config settings for localized sites, username_2. Wasn't quite sure if I encountered problems because me redefining `siteUrl` with `define('CRAFT_SITE_URL', '{siteUrl}en/');` in `en/index.php`. Additional question: is the "new" technique to set `siteUrl` with an array `'siteUrl' => array('de' => 'http://example.com/', 'en' => 'http://example.com/en/')` preferable?  
  > **username_0**: Thanks username_2. I thought of the 'baseResourceUrl' option but thought there might be a simpler solution.  
  > **username_2**: @ChristianSeelbach Yes the new [siteUrl](http://buildwithcraft.com/docs/config-settings#siteUrl) config setting is a better way to define locale-specific URLs than defining CRAFT_SITE_URL constants. With the config setting, Craft will know what an entry’s URL is in all locales, so “Share” links will always be correct, for example.  
  > **username_4**: @username_2 Not to be a jerk, but there's a typo (`baseReaourceUrl`) in the third code block I can't edit. People like me copy those things and become confused later.  
  
  ---
  
  ### Answer by username_1 on 2014-06-26. Score: 4
  
  You need to make the url absolute, or relative to the root. The url() function will help you to keep this maintainable.
  
  ```
  {{ url('assets/build/css/main.css') }}
  
  ```
  
  This will prepend the {{ siteUrl }} to the path, so if you move the site later, or are running in a multi environment setup, the path will be updated.
  
  > **Comments:**
  > **username_2**: A word of warning about `url()`: it is subject to whether Craft thinks the server supports index.php redirecting, even if you're only pointing it to a static file. So only use it with static file URLs if you've set the [omitScriptNameInUrls](http://buildwithcraft.com/docs/config-settings#omitScriptNameInUrls) config setting to `true`.  
  
  ---
  
  