Answers.Body: <p>ok so after quite a few days, craft then updated and now it works. I didn't really do anything to fix it it just worked after updating</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-09T10:36:54.867Z
Answers.LastActivityDate: 2021-06-09T10:36:54.867Z
Answers.UserDisplayName: Steven Zhang
Answers.Body: <p>Why use <code>includeCssFile</code> at all for your core CSS? Typically you'd use that for injecting template-specific CSS files (e.g. carousel scripts) that you don't want to load on every page. (The advantage is that you can call that includeCssFile function in deeply nested templates without worrying about template inheritance or whether another partial has already included that CSS file).</p>
  <p>So in short, just use a normal <code>&lt;link rel=&quot;stylesheet&quot; href=&quot;/css/main.css&quot;&gt;</code> for your core CSS file.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-02T11:20:33.277Z
Answers.Text: I tried this and it didn't make any difference unfortunately
Answers.UserDisplayName: Steven Zhang
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-08T12:02:20.443Z
Answers.Text: If that doesn't work, then really your problem is nothing to do with Craft.
Answers.UserDisplayName: James Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-09T13:11:08.373Z
Answers.Text: This is the correct answer IMO. FYI ``includeCssFile`` is being [deprecated](https://craftcms.com/docs/3.x/upgrade.html#template-tags) as of Craft 3 so you'd want to replace with ``do view.registerCssFile`` as well.
Answers.UserDisplayName: RitterKnight
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-01T10:34:02.337Z
Answers.LastActivityDate: 2021-06-01T10:34:02.337Z
Answers.UserDisplayName: James Smith
Answers.Body: <p>Can you please try <code>{%includeCssFile &quot;/css/main.css&quot;%}</code> (prepend with a /)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-31T13:43:39.523Z
Answers.Text: I changed `{%includeCssFile "css/main.css"%}` in my _layout.html template file to `{%includeCssFile "/css/main.css"%}` but now none of my web pages have css styling anymore, including my home page which worked before
Answers.UserDisplayName: Steven Zhang
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-31T15:26:22.593Z
Answers.Text: your CSS file is located in <projectRoot>/web/css/main.css. can you confirm that?
Answers.UserDisplayName: Matthias Redl-Mann
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-01T01:47:14.450Z
Answers.Text: Yep! my CSS file is in web/css/main.css
Answers.UserDisplayName: Steven Zhang
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-01T05:59:48.417Z
Answers.Text: OK, no clue why it does not work, but it must be something very obvious we are missing here. Without seeing this on a public server I can not go further into detail. If you want, you can send me a public URL via E-Mail at mr@getdesigned.at and I will have a look...
Answers.UserDisplayName: Matthias Redl-Mann
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-31T12:13:03.693Z
Answers.LastActivityDate: 2021-05-31T12:13:03.693Z
Answers.UserDisplayName: Matthias Redl-Mann
Body: <p>So I am making a new craft cms website, I have my page entries linked to the template pages/_entry.html, which works fine. I then made another type of pages called news, linked to the template news/entry.html. Both of them have <code>{% extends &quot;_layout&quot; %}</code> to get a common layout and the css styling. when I click preview, the page entries work (including css) but the CSS of news entry doesn't show up, it simply goes to the default styling (which is no styling).
  I tried making both the news and page entries have their templates linked to pages/_entry.html, and once again, only the page entries show up with proper css styling but not the news entry. I tried this with a product in craft commerce as well, and the same happened where no styling would be present.
  I even tried switching both news and page entries to news/entry.html but with no luck, I get the same result.</p>
  <p>Is this a bug with craft cms or am I doing something horribly wrong?</p>
  <p>both pages/_entry.html and news/_entry.html only have <code>{% extends &quot;_layout&quot; %}</code> for now to troubleshoot this process. In my _layout.html I have <code>{%includeCssFile &quot;css/main.css&quot;%} </code> to link to my css file.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-30T17:32:25.837Z
Comments.Text: How do the URLs or your 2 sections "pages" and "news" look like? I guess it is just a relative path problem to your css file.
Comments.UserDisplayName: Matthias Redl-Mann
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-31T11:07:57.663Z
Comments.Text: @MatthiasRedl-Mann my URL for "pages" looks like:
  Entry URI Format: {slug}
  Template: pages/_entry
  
  my URL for a product page looks like:
  Entry URI Format: shop/products/{slug}
  Template: pages/_entry
  
  my URL for "news" page looks like:
  Entry URI Format: {postDate.year}/{slug}
  Template: pages/_entry
  
  all three of them point to the same template, but only the "pages" have the proper CSS displayed, the rest have no CSS
Comments.UserDisplayName: Steven Zhang
Tags: <craft3><templating><plugin-craftcommerce><css>
Title: CSS file not being read by other templates
ThreadText: # CSS file not being read by other templates
  
  (Asked by: username_0 on 2021-05-30)
  
  So I am making a new craft cms website, I have my page entries linked to the template pages/\_entry.html, which works fine. I then made another type of pages called news, linked to the template news/entry.html. Both of them have `{% extends "_layout" %}` to get a common layout and the css styling. when I click preview, the page entries work (including css) but the CSS of news entry doesn't show up, it simply goes to the default styling (which is no styling).
  I tried making both the news and page entries have their templates linked to pages/\_entry.html, and once again, only the page entries show up with proper css styling but not the news entry. I tried this with a product in craft commerce as well, and the same happened where no styling would be present.
  I even tried switching both news and page entries to news/entry.html but with no luck, I get the same result.
  
  Is this a bug with craft cms or am I doing something horribly wrong?
  
  both pages/\_entry.html and news/\_entry.html only have `{% extends "_layout" %}` for now to troubleshoot this process. In my \_layout.html I have `{%includeCssFile "css/main.css"%}`  to link to my css file.
  
  **Tags:** craft3, templating, plugin-craftcommerce, css
  
  > **Comments:**
  > **username_1**: How do the URLs or your 2 sections "pages" and "news" look like? I guess it is just a relative path problem to your css file.  
  > **username_0**: @username_1 my URL for "pages" looks like: Entry URI Format: {slug} Template: pages/_entry  my URL for a product page looks like: Entry URI Format: shop/products/{slug} Template: pages/_entry  my URL for "news" page looks like: Entry URI Format: {postDate.year}/{slug} Template: pages/_entry  all three of them point to the same template, but only the "pages" have the proper CSS displayed, the rest have no CSS  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2021-06-09. Score: 0 | Accepted answer
  
  ok so after quite a few days, craft then updated and now it works. I didn't really do anything to fix it it just worked after updating
  
  
  ---
  
  ### Answer by username_2 on 2021-06-01. Score: 3
  
  Why use `includeCssFile` at all for your core CSS? Typically you'd use that for injecting template-specific CSS files (e.g. carousel scripts) that you don't want to load on every page. (The advantage is that you can call that includeCssFile function in deeply nested templates without worrying about template inheritance or whether another partial has already included that CSS file).
  
  So in short, just use a normal `<link rel="stylesheet" href="/css/main.css">` for your core CSS file.
  
  > **Comments:**
  > **username_0**: I tried this and it didn't make any difference unfortunately  
  > **username_2**: If that doesn't work, then really your problem is nothing to do with Craft.  
  > **username_3**: This is the correct answer IMO. FYI ``includeCssFile`` is being [deprecated](https://craftcms.com/docs/3.x/upgrade.html#template-tags) as of Craft 3 so you'd want to replace with ``do view.registerCssFile`` as well.  
  
  ---
  
  ### Answer by username_1 on 2021-05-31. Score: 1
  
  Can you please try `{%includeCssFile "/css/main.css"%}` (prepend with a /)
  
  > **Comments:**
  > **username_0**: I changed `{%includeCssFile "css/main.css"%}` in my _layout.html template file to `{%includeCssFile "/css/main.css"%}` but now none of my web pages have css styling anymore, including my home page which worked before  
  > **username_1**: your CSS file is located in <projectRoot>/web/css/main.css. can you confirm that?  
  > **username_0**: Yep! my CSS file is in web/css/main.css  
  > **username_1**: OK, no clue why it does not work, but it must be something very obvious we are missing here. Without seeing this on a public server I can not go further into detail. If you want, you can send me a public URL via E-Mail at mr@getdesigned.at and I will have a look...  
  
  ---
  
  