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

Investigate the use of <base> instead of linkPrefix #161

Closed
gesposito opened this issue Feb 28, 2016 · 7 comments
Closed

Investigate the use of <base> instead of linkPrefix #161

gesposito opened this issue Feb 28, 2016 · 7 comments

Comments

@gesposito
Copy link
Contributor

I think linkPrefix might be some (unnecessary) overhead for newcomers, we could use:

https://developer.mozilla.org/en/docs/Web/HTML/Element/base

http://webdesign.tutsplus.com/articles/quick-tip-set-relative-urls-with-the-base-tag--cms-21399

@KyleAMathews
Copy link
Contributor

Wow... I've never heard of actually. Yeah, this looks perfect. So it looks like we could keep things basically as they are now except when someone builds with --prefix-links, that'd be a cue to the html.js to add the <base> tag?

It seems like browser support is near 100%. Is there any downsides to using this technique?

@gesposito
Copy link
Contributor Author

Only downside that I understand is that it needs an absolute path, so linkPrefix (or whatever we want to call the <base> url) needs to be the "production" url.
Then, any relative url (assets/, Link to, etc) is going to be relative to the root <base> url, therefore prefixed.

@KyleAMathews
Copy link
Contributor

But you should only prefix links for production? I can't think of any other
time it'd be useful.
On Mon, Feb 29, 2016 at 2:02 AM Gianluca Esposito notifications@github.com
wrote:

Only downside that I understand is that it needs absolute path, so
linkPrefix needs to be the "production" url.
Then, any relative url (assets/, Link to, etc) is going to be relative to
the root url.


Reply to this email directly or view it on GitHub
#161 (comment).

@gesposito
Copy link
Contributor Author

Yes, same use of linkPrefix

<base href="https://example.github.io/your-project/">

when you want to prefix all relative links with /your-project/

Only needed for production (no need for localhost, since Gatsby is "normalizing" the url) AND root path is not /.

@KyleAMathews
Copy link
Contributor

After some googling, it looks like the tag has some serious downsides...

Leaning towards closing this... thoughts @gesposito?

@gesposito
Copy link
Contributor Author

Looks like the only problem we might care about (other two are old issues) is the behaviour with #anchor links.
We can go ahead and close this, I'll try to dig deeper if I'm able to.

@KyleAMathews
Copy link
Contributor

Yeah, breaking #anchor links is my main concern as they're often used on static sites.

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