1

This is the template im using and the index of the file is taking the css and printing it nicely however, the _entry.twig is only loading text, please check out the screenshots.

Below is the index of directory which loads css completely fine.

And one after is the _entry.twig which isn't taking any CSS. index of the directory

This is _entry.twig of the same directory which isn't loadingany css

Thanks!

  • Is your _entry.twig template using {% extends '_layout' %} at the top? Either that, or the <style> tag in your layout is using a relative link like "/style.css" instead of an exact link like "{{ siteUrl }}style.css". – Jon Weedin Feb 11 at 13:55
  • Thank you for the reply. _entry.twig does have {%extends '_layout' %} at the top, and style tag in the header is as follows <link rel="stylesheet" href = "css/styles.css">. the css directory is in web folder, and its taking style in index but not in _entry.twig. NOTE : css style is being fetched in other _entry.twig of single page. – Shabaz Khan Feb 11 at 22:49
  • Do you have a 404 error in your console for the CSS file? – Jon Weedin Feb 12 at 2:09
  • I tried doin' this copied style.css from css/style.css and pasted it in template directory and under layouts/_main i changed the path from <link rel="stylesheet" href = "css/styles.css"> to <link rel="stylesheet" href = "/styles.css">. as a result now when I hit _entry.twig slug the page just keeps loading, not sure if this qualifies to be 404 error. – Shabaz Khan Feb 12 at 3:43
  • Your styles.css file should be in your web folder, not in templates. When the styles.css file is in your web folder, if you open up Developer Tools and click Console, do you see a red 404 error that it can't find your styles.css file? – Jon Weedin Feb 12 at 4:26
1

Are you using a relative file path? Try to omit them where you can and see if it resolves?

  • I typically use {{ siteUrl }} before ANY relative path to avoid the hassle. I recommend it for all templates that use any kind of directory for static images or for js or css called in multiple places with multiple layouts – Jessie Gilligan Feb 13 at 20:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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