sondr3 / generator-jekyllized

A Yeoman generator for Jekyll to rapidly build sites using Gulp
MIT License
326 stars 35 forks source link

Assets not linked correctly on gh-pages #146

Closed architektloew closed 7 years ago

architektloew commented 8 years ago

Hi, first thanks for the generator, it works great. I developed my page and deployed it to gh-pages, but there none of the assets are linked correctly. I linked everything as href="/assets/images etc. Do I need to setup anything like baseurl etc in config.yml or should it work out of the box. If I set a baseurl I see that the canonical link in the generated html is a combination of the site.url and site.baseurl which seems wrong. I tried finding help in the readme and old issues but could not solve this yet. Thanks in advance.

sondr3 commented 8 years ago

I'll take a look tonight :)

sondr3 commented 8 years ago

It's because you've specified the URL wrong, I'm guessing you want your site to be served as architektloew.github.io and not architektloew.github.io/architektloew? Because in that case you need to rename your repo to architektloew.github.io and then it should work. You also need to enclose your Liquid tags with {% %}, not just { }.

architektloew commented 8 years ago

Hi, thanks for taking the time to take a look and your answer. I changed the repo name tp architektloew.github.io but now it shows a 404 when visiting that URL. I also changed the remote to point to that repo and did another gulp deploy.

When you say "it should work", do you mean I can leave all my links just in that format href="/assets/images/" etc or will I have to add something like href="{{ site.url }}/assets/images/". Sorry maybe I am missing something really obvious here. After changing the repo I received a Github email saying

The page build completed successfully, but returned the following warning:

You are currently using the 'redcarpet' Markdown engine, which is no longer supported by GitHub Pages and may cease working at any time. To ensure your site continues to build, remove the 'markdown' setting in your site's '_config.yml' file and confirm your site renders as expected. For more information, see https://help.github.com/articles/updating-your-markdown-processor-to-kramdown.

But that should not be related in any way I think...

sondr3 commented 8 years ago

Hmm, it looks correct to me, but it might be that it's because you've renamed it that it isn't working properly, I'd delete the repository and create a new one called architektloew.github.io and push your site to it. And yes, keeping the links as href=/assets/ etc will work fine without using {{ site.url }} because without a prepending URL it will just default to the base domain name it's being served from.

sondr3 commented 8 years ago

You may also have to follow the steps here: https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/. Not really sure, Github changed how they publish sites recently and I haven't used it in quite a while.

architektloew commented 8 years ago

Okay, sounds great. I deleted the repo and recreated it, but still getting the 404 from Github. I will try to solve this tomorrow, should be something really obvious that I am missing here with gh-pages.

I think I have to set gulp-gh-pages to use the 'master' branch for 'username'.github.io repos (see https://github.com/shinnn/gulp-gh-pages) then it should work.

But when I try this I am getting

❯ gulp deploy                                                                                                                                                                                                                            [0m]
[22:58:58] Using gulpfile ~/projects/clients/architekt-loew/loew-gulp/gulpfile.js
[22:58:58] Starting 'deploy'...
[22:58:58] Starting 'upload'...
[22:58:59] [gh-pages (master)] Cloning repo
[22:58:59] [gh-pages (master)] Checkout branch `master`
[22:58:59] 'upload' errored after 210 ms
[22:58:59] Error in plugin 'gulp-gh-pages'
Message:
    Command failed: git checkout  master
error: you need to resolve your current index first

Details:
    killed: false
    code: 1
    signal: null
    cmd: git checkout  master
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false
[22:58:59] 'deploy' errored after 213 ms

But I should be able to solve that. Thanks for your help, will close that issue hopefully tomorrow and report back.

sondr3 commented 8 years ago

You can't set it to master when you've already pushed to master using normal git since it can't resolve the two different branches. I'm creating my own repo to try this out real quick.

sondr3 commented 8 years ago

Ah, right, I mentioned in the README that if you are using a username.github.io repo you must serve from the master branch, so you need to delete the master branch and repush the newly created site and then maybe create a branch called source for the actual source.

architektloew commented 8 years ago

yeah that's what I did (using a develop branch). Still the gulp deploy job always errors if branch is set to master even when I completly reset git in that repo. Same error as above. Anyway, will figure that out tomorrow. :)

sondr3 commented 8 years ago

Yeah, I'm seeing that too, it's a problem with the damn Gulp plugin that I'm using because it tries to pull from the remote when deploying and since the branch doesn't exist it crashes. I see there are open issues for it on it's Github page.

sondr3 commented 8 years ago

Okay, since this is an issue with the gulp plugin it's actually a major bug. I see it hasn't been updated in a year so I'm going to look for alternatives and remove it.

architektloew commented 8 years ago

Ah okay. To be honest I don't need to set it up in the "username.github.io" way. If I use a different repo name and get the "username.github.io/reponame" url, will I have to adjust anything regarding assets like baseurl etc? (back to original question) I am planning to use a custom domain anyway.

sondr3 commented 8 years ago

If you are planning to use a custom domain you don't need to change it since by default it always looks for assets at the baseurl. At least you shouldn't, and I haven't heard anything else from anyone else.

sondr3 commented 8 years ago

Okay, I've pushed a new version of the generator to NPM, so you should update it and run yo jekyllized:update in your project root and it'll update the gulp tasks to be able to correctly push to Github. Let me know how it works :)

tmaximini commented 8 years ago

Thanks after the update everything works perfectly. 👍 good job

deontologic commented 8 years ago

Is this issue resolved? I'm trying to deploy to kantianethics.github.io/test

I set url: https://kantianethics.github.io, and baseurl: test in _config.yml, but the injected JS and CSS is not linked correctly.

I'm using a custom domain as well.

deontologic commented 8 years ago

For your reference, these are the changes I made to correctly deploy to github pages with a baseurl:

https://gist.github.com/kantianethics/3cb33a242c1532a398517a0bdd933373

This is not an optimal solution, though.

sondr3 commented 8 years ago

Shouldn't be a problem, no, but why are you deploying like that with a baseurl? Regardless, if you had a working scenario where I could take a look that'd be nice.

sondr3 commented 7 years ago

Closing for inactivity.