digitalcraftsman / hugo-strata-theme

Port of HTML5UP's Strata theme to Hugo
Other
143 stars 92 forks source link

Use relative vs absolute links #1

Closed marvinpinto closed 8 years ago

marvinpinto commented 8 years ago

This allows the site to be run with any base url and thus easier to test and such.

digitalcraftsman commented 8 years ago

Hello @marvinpinto,

could your explain in more detail why relative urls have an advantage over the use of the base url? You could set the base url to every path you would like in the configs.

One problem with relative urls is that they're relative to the domain of the host and not to the folder in which the site resides. For example, I'm hosting the site in the root directory and want to access some assets:

 www.example.com/path/to/asset.css

This would work fine. But some people decide to host their site in a subfolder, like www.example.com/blog/.

Now, the browser would look for the assets in the root directory like above, but instead the correct path would be

www.example.com/blog/path/to/asset.css

There were also some other discussions about using relative links.

marvinpinto commented 8 years ago

Ahh, you bring up a very good point! Instead of me messing with the Site.BaseURL lines, how do you feel about this:

-@import url("http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400italic");
+@import url("//fonts.googleapis.com/css?family=Source+Sans+Pro:400,400italic");

Would allow a site to be served off either http or https, and not throw "insecure content warnings" for the latter. Thoughts?

digitalcraftsman commented 8 years ago

That is a very good idea. I've made the request protocol independent. See fae40ef79655250cd99b044997e4fabed284c18f

marvinpinto commented 8 years ago

Cool :+1:

I'll close this PR then.