2

I'm finally getting around to migrating my blog to some markdown goodness and hexo seemed to be the best option for me. I seem to be missing something about the workflow from hexo project to github pages though.

Should the hexo project live in one repo and then publish the generated content to a separate pages repo? Or is there some other mechanism (like branching) that should be used?

The former seems to be the most likely but I thought I'd ask first. Sorry if it seem s obvious, I may have confused myself reading about jekyll etc earlier.

flukus
  • 996
  • 8
  • 18

2 Answers2

10

Depending of the type or site your deploying : user/organization or project, your code must be respectively pushed in master or gh-pages branch (see gh page doc here).

http://flukus.github.io/ -> master

http://flukus.github.io/myproject -> gh-pages

Setup you github configuration (or other hoster) in you _config.yml like described here.

Additionally you'll have to create an empty .nojekyll file at the root of your repository to instruct Github pages not to process you site as a Jekyll site.

hexo generate --deploy will then do it well.

David Jacquel
  • 51,670
  • 6
  • 121
  • 147
  • Well its a personal blog, so the generated pages go to master. But should source markdown, templates, etc live in a different branch or different repo? – flukus Dec 10 '14 at 20:41
  • Source code must not live in the same repository, but you can version it in an other branch or another repository. – David Jacquel Dec 10 '14 at 20:58
  • Thanks, that's what I thought but it isn't actually stated in the docs as far as I could see. – flukus Dec 10 '14 at 21:02
1

maybe you can build a repo, the constructure is like this:

  • repo: xxx.github.io
    • branch: hexo(store your hexo source file)
    • branch: master(store you Blog static pages)

and set the branch hexo to default branch.

and now, build the hexo environment, just mkdir a new floder like D:\hexo, and npm install hexo,hexo init,npm install,npm install hexo-deployer-git

then, connect you local floder to your github repo, git bash here:

cd D:\hexo
git init
git remote add origin <your github repo clone url>
git checkout hexo

then update the .gitignore file, add a ilne:

public/

then update your _config.yml:

deploy:
    type: git
    repo: git@github.com:xxx/xxx.github.io.git #your own ssh url, http url is also ok
    branch: master

the git bash here:

git add .
git commit -m "haha"
git push -f origin hexo

last, deploy your Blog:

hexo d -g
yanss
  • 126
  • 1
  • 6