1

I've attached a screenshot of the code I'm using to link to the CSS files on my server. Am I using the wrong path??

The site I'm working on is http://www.bookslibrarianslove.com/index.php/Pages

Many Thanks!

enter image description here

1

Yes, you are. And your question is almost off topic.

  • EECMS variables are put between { and }. You should put variables there, not only paths. Path variables are a little different. You can study all about it on Template Language Overview;
  • public_html is usually the folder where the website is. Everything accessible from web is inside this folder, so you need to point to its contents, not to the folder itself;
  • paths initiating with / are followed from the domain root. They're called "root relative paths". For example, /my-file.gif can be accessed from anywhere on the domain;
  • paths without a / as first character are followed starting at the folder you already are. They're the "relative paths". For example, if you are on http://domain.com/page_1/page_23, a path like my-file.gif will point to http://domain.com/page_1/page_23/my-file.gif. They can give you headaches;
  • paths starting with protocol and domain are called "absolute paths";
  • CSS can be saved as a EECMS Template and linked using {stylesheet='template_group/css_template'}, but you usually don't need that;

Since the CSS isn't being served by EECMS, you can point directly to it in two ways. Using a root relative path:

<link rel="stylesheet" href="/css/style.css" />

Or an absolute path:

<link rel="stylesheet" href="{site_url}/css/style.css" />

EECMS will replace the {site_url} variable with the setting used on URL to the root directory of your site on Control Panel. Pay attention to not have double / or a missing one.

1
  • Robson, off-topic comment... you use the English contraction "you're" incorrectly. No one says "you're" in place of "you are" in sentence termination in it's 2nd person singular present context. It's very confusing, no one expects "you're" to not have a following adjective, so it sounds like you're ending your sentences with "your", even when reading it. :P
    – jrothafer
    Oct 2 '15 at 14:30
0

Nope! , erm, I mean Yup! You have the wrong value for the src parameter.

<link rel="stylesheet" href="{site_url}css/style.css" />

Use that (assuming this is an ExpressionEngine parsed template). You might need to add a / after {site_url}, depending on what your site url config var is set to.

11
  • Thank you @jrothafer. BTW, I sent you an invite on LinkedIn. Oct 8 '15 at 22:32
  • Okay, I'm still tinkering with this issue, and have provided an updated screen shot. Oct 8 '15 at 22:33
  • Dot to the dot dot (...) your new screen shot shows that this template is not getting parsed by ExpressionEngine at all. Is it a template in a template group? That is set to "Website" as type, instead of say "CSS" or something else? Let me clear this up, go and edit this page, and take a screenshot of you editing it, and add that to your question.
    – jrothafer
    Oct 8 '15 at 22:43
  • Wait, wait wait... why are your styles sheets in a <noscript> block??
    – jrothafer
    Oct 8 '15 at 22:47
  • The code lives in the PageElements/.header template Oct 8 '15 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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