0

I'm new to EE and I have an issue linking to bootstraps folder. The default_site template (home page) stylesheet link to assets folder works fine, but when I make a new template_group and then a new template the links won't work. Any idea why the default_site template links work, but new template links won't? Here are the links to the bootstrap folder:

<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic">
<link rel="stylesheet" href="/assets/fonts/font-awesome.min.css">

2 Answers 2

1

It's because you're using a relative path for <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css"> instead of an absolute.

Your default template works because your index file is on the same directory level as your assets folder.

Example:
https://mysite.com/index.php
https://mysite.com/assets/...

However, when you don't use a leading slash in your URL, the path is relative to where you are in the directory structure.

Example:
A link to the file assets/mystyles.css from the URL https://mysite.com/subpage would be the same as saying https://mysite.com/subpage/assets/mystlyes.css

Using an absolute path, tells the server you want to go back to the top of the tree to access this path. Thus you would want to use /assets/mystyles.css

Example:
A link to the file /assets/mystyles.css from the URL https://mysite.com/subpage would be the same as saying https://mysite.com/assets/mystlyes.css

When you use the {site_url} variable, an absolute URL is created. Using {site_url}assets/mystyles.css would render in the browser as https://mysite.com/assets/mystyles.css

Hope that helps.

0
0

I found the solution, by adding {site_url} it worked, but I don't need it for the default_template. Maybe someone knows why?

href="{site_url}assets/bootstrap/css/bootstrap.min.css"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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