Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop "{{.Site.BaseURL}}" from templates #18

Closed
dencold opened this issue Aug 3, 2016 · 1 comment
Closed

Drop "{{.Site.BaseURL}}" from templates #18

dencold opened this issue Aug 3, 2016 · 1 comment

Comments

@dencold
Copy link
Owner

dencold commented Aug 3, 2016

Holdover from the original theme. All assets use a template variable that gets expanded with the actual site name. This isn't necessary and can just be linked with the root version instead.

For example:

<link rel="stylesheet" type="text/css" href="{{.Site.BaseURL}}css/screen.css" />

can become:

<link rel="stylesheet" type="text/css" href="/css/screen.css" />

Here is a link to one file that is in violation:

<link rel="shortcut icon" href="{{.Site.BaseURL}}images/favicon.ico">

@dencold
Copy link
Owner Author

dencold commented Jan 13, 2017

I've revisited this and have decided my original intuition is not correct. The .Site.BaseURL parameter can be very helpful for users who use hugo for serving content from a specific location that isn't at the server root. A common example is http://mywebsite.com/blog.

Without using BaseURL the user would be forced to locate all resources (like css/js/etc.) at the root directory, but maybe they have an application running there and that has its own set of assets. If we use BaseURL we can encapsulate everything we need in the static site. Much better approach.

I will close this and open a new issue that does the opposite: makes sure that .Site.BaseURL is being used everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant