-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
baseurl / base-url: GitHub Pages Project Pages - Relative Links Fail #332
Comments
Personally I would prefer it to be shorter since you would need to be typing this A LOT Then on a page you have |
Use the HTML |
|
+1 |
My links to posts currently look like Also why is it |
Its simpler to use the config.yml baseurl line to add it as html base in head of html than you never are editing hrefs ever..:) |
Is this still unfixed? Even if I add baseurl to my |
I am also interested in a solution... |
@7Andrew: unfortunately your solution does not work in platform redirect files such as:
|
👍 |
Any solution? I would like to be able to have relative links work in GitHub pages as well as locally. |
No solution for this yet? |
What I've done to make paths work both locally and on my ghPage is to create a _config.yml file that I then add to my .gitignore where I define a url variable for my local path. Then I use {{ site.url }} in paths to create full absolute urls. However, since the config file doesn't get uploaded when I push to GitHub, the {{ site.url }} is ignored there and the paths stay relative on my ghPage. I just tried this and it works, but I am still in process of putting my ghPage together so I've only tried it on my index page and my test post. |
This is still a big issue for serving html pages in subfolders and linking them to css in root on Github Pages |
According to all of the documentation I have, |
@parkr The problem here is that if you serve a website via Github Pages, the url looks like <link href="/css/reset.css" rel="stylesheet" type="text/css">
<link href="/css/styles.css" rel="stylesheet" type="text/css">
<link href="/css/syntax.css" rel="stylesheet" type="text/css"> this makes sense, the browser will look for files under the root/css/, i.e.
which makes the site work for documents in the root, but still breaks for any subfolders. |
@parkr I'm suffering from this issue too, just as @archseer described. I've a custom domain properly setup at my older user GitHub page. Now I'm trying out a Jekyll project page, first I've checked that
instead of previous
but still, this solved things partially, at the index page there's:
When I load the page, So, how do I config a simple GitHub Pages hosted |
I got Even then, I'm not sure it was the proper way to fix this. |
ok, I figured it out for serving locally, I must put the ending slash: So, everything is working, the only thing that I find cumbersome now is that I must put |
So, what is the solution? |
I finally figured out the trick, if you're looking for a solution with the standard URL for GitHub Pages ( In Now you'll need to change the way you do links in your templates and posts, in the following two ways: When referencing JS or CSS files, do it like this: When doing permalinks or internal links, do it like this: Finally, if you'd like to preview your site before committing/deploying using This way you can preview your site locally from the site root on localhost, but when GitHub generates your pages from the gh-pages branch all the URLs will start with |
Excellent solution, @mjswensen. Thorough and helpful. Thanks. |
@aseemk No sweat! |
I doesn't seems different from what I've gone through, except that I never need to use |
@mjswensen Thanks for the solution. That worked. on a different note, what a PITA. |
@mjswensen Would you want to write that up and submit a PR to the docs site for us? |
@parkr Be happy to. |
it work with me when index.html file is in the root directory |
here example [ https://github.com/almgwary/almgwary_gallary/blob/gh-pages/index.html ] |
http://stackoverflow.com/questions/16316311/github-pages-and-relative-paths led me to this (almost didn't notice it!): jekyll/jekyll#332 (comment) This works on localhost. Now I'll see if it works on github.io.
…andrewspiers comment on jekyll/jekyll#332, but unable to test locally
- When we moved from Custom Domain to Github Project few links were not working - Fixed those links - check jekyll/jekyll#332 to know how this fix works
This simple set up works for me: It will redirect to http://<absolute&belovedURI>/sitemap |
If you're not using a CNAME and hosting your Project Page on GitHub Pages it's served out of a "project-name" subfolder
http://user-name.github.com/project-name
Relative url's fail:
<a href="/">home</a>
resolves to
http://user-name.github.com/
Another example:
<a href="/blog">blog</a>
resolves to
http://user-name.github.com/blog
when I needed:
http://user-name.github.com/project-name/blog
The workaround I can think of for this is setting a "base-url:" in the
_config.yml
then put that in front of allhref
,src
,url
paths ... need it in .css and .js files, so they need to run through Jekyll (see: http://stackoverflow.com/questions/4305955/can-jekyll-act-over-css-or-js-files)... a "base-url:" is suggested in the wiki here: https://github.com/mojombo/jekyll/wiki/Configuration ... but I can't seem to find anything that explains how this should be implemented within your actual files. e.g.<a href="{{ site.base-url }}/blog">blog</a>
... am I missing something here? Is there a more elegant solution?
The text was updated successfully, but these errors were encountered: