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

fix: always use absolute URLs for assets, including protocols #65

Closed
wants to merge 1 commit into from

Conversation

keithamus
Copy link
Member

Fixes #64

You can make them absolute which tends to make development across forks/repos easier:

<link href="{{site.github.url}}/css/....">

Locally site.github.url is just ''. When served through gh-pages it'll be https://tc39.github.io/beta, and when forked to e.g. me it'll be https://keithamus.github.io/beta

Also while on the topic of URLs - it is preferred to avoid protocol relative URLs (that is, urls without the http, e.g. src="//cdnjs.cloudflare.com...". This should be avoided because if you have an https capable asset, it should ideally always be served with https. (See https://www.paulirish.com/2010/the-protocol-relative-url/)

@ljharb
Copy link
Member

ljharb commented Jun 13, 2018

I'm confused about why we wouldn't use / (iow, root-relative URLs) which would handle inserting the right domain name in every case.

@Regaddi
Copy link
Contributor

Regaddi commented Jun 13, 2018

The fix doesn't work for me locally 😔. It tries to access e.g. https://github.com/pages/Regaddi/tc39-beta/assets/css/style.css?v=65d61e221df72a92b2a79d4987135c9fd8e9243f instead of /assets/css/style.css?v=65d61e221df72a92b2a79d4987135c9fd8e9243f.

Do I miss some configurational part?

@IgnoredAmbience
Copy link
Contributor

@ljharb Root-relative URLs would fail when the repository is forked and/or renamed, for example if I wanted my fork to be named "tc39-website" instead of "beta".

@ljharb
Copy link
Member

ljharb commented Jun 14, 2018

@IgnoredAmbience interpolating the repo name makes sense to me, I’m just asking about the full url with domain - can we do just the repo name?

@keithamus
Copy link
Member Author

I personally don't know of a way to do the relative URL. I think the function just reads from config. Happy if someone can come up with a better solution but this is how I know how to do it.

@codehag
Copy link
Collaborator

codehag commented Jun 14, 2018

netlify was failing due to the repo name changed, should be fixed now

@jasonwilliams
Copy link
Member

@codehag still failing :/

@jasonwilliams
Copy link
Member

@keithamus This isn't working locally.
links are resolving to:
https://github.com/pages/tc39/beta/assets/js/main.js?v=7a0521117545f2971647f6d467df9062e035beef
https://github.com/pages/tc39/beta/assets/css/style.css?v=7a0521117545f2971647f6d467df9062e035beef
https://github.com/pages/tc39/beta/assets/css/style.css?v=7a0521117545f2971647f6d467df9062e035beef

@codehag
Copy link
Collaborator

codehag commented Jun 29, 2018

Fixed by #72

@codehag codehag closed this Jun 29, 2018
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

Successfully merging this pull request may close these issues.

6 participants