title: Jekyll versioning workflows layout: page
You have two options when it comes to host a Jekyll site on Github pages :
You just have to ask few questions :
If the answer to any of this questions is yes then you should use multi-branch versioning. Otherwise, stay with the basic versioning.
You host your site on Github pages and just have to push your code :
Just need a git push origin master
or git push origin gh-pages
and Github will build you site just fine.
This is the simplest versioning worflow.
If you need some plugins (generator, tag, ...) or build tasks (gulp, grunt, ...) they will not run on gh-pages. So, you will have to build you site before pushing the resulting pages on github (or on any server that can serve static pages).
For a User/Organization site, it will be master branch for the site build, and sources branch (or any name you like) for the code. It will be versioned at github.com/userName/userName.github.io and hosted at https://userName.github.io.
For a Project site, it will be gh-pages branch for the site build, and master branch (or any name you like) for the code. A Project site will be versioned at github.com/userName/projectName and hosted at https://userName.github.io/projectName.
Both repository can also have a custom domain name, but it's another story.
Check out the Rakefile !
It can do :
In order to publish :
Once you've set the parameters in the head of the Rakefile, you can launch the installation by doing :
create a repository on github (eg: https://github.com/userName/userName.github.io)
in the console do cd pathTo/yourJekyllSource
then wget https://raw.githubusercontent.com/djacquel/JekyllVersioningWorkflows/master/Rakefile
will save the Rakefile in your repository.
be sure that you have the push permission on the Github repository
edit the Rakefile and set parameters.
in the console do : rake setup
And it's done !
In the background, and depending if we deal with a User/Organization (UO) site or a Project site (P), rake setup
does :
git init
git remote add origin [email protected]:userName/userName.github.io.git
(UO) or git remote add origin [email protected]:userName/repositoryName.git
(P)
jekyll new .
creates your code base
in _config.yml, set the baseurl parameter to baseurl: '' (UO) or baseurl: '/repositoryName' (P)
in .gitignore add _site, it will be versioned in the other branch
jekyll build
will create the destination folder and build site.
git checkout -b sources
(UO) or git checkout master
(P)
git add -A
git commit -m "jekyll base sources"
commit your source code
git push origin sources
(UO) or git push origin master
(P) push your sources in the appropriate branch
cd _site
touch .nojekyll
, this file tells gh-pages that there is no need to build
git init
init the repository
git remote add origin [email protected]:userName/userName.github.io.git
(UO) or git remote add origin [email protected]:userName/repositoryName.git
(P)
git checkout master
(UO) or git checkout -b gh-pages
(P) put this repository on the appropriate branch
git add -A
git commit -m "jekyll first build"
commit your site code
git push origin master
(UO) or git push origin gh-pages
(P)
Feel free to fork my repository if you want to enrich the code.