One line deployment of your site to gh-pages

  |   Source   |   Minimap   |   Note: Just click on any IPython input cell to see the output.

Do you want to easily deploy your site to Github pages?

OK, here we go...

  1. You have to upload your complete blog/site to a new Github repository (you know how to do it... if not, probably you need to learn some things before try this one, hehe). As a plus, now your blog/site is version-controlled!

  2. Almost for sure, your site/blog lives in the master branch of the new repository, but you need to generated a gh-pages branch to push your build or output folder, I mean your site/blog content to deploy... not all the machinery of your site/blog platform (Nikola in my case):

  • git checkout -b gh-pages
  • git rm -rf .
  • git commit -am "First commit to gh-pages branch"
  • git push origin gh-pages
  1. Now, we will use a git-subtree technique to push the build or output content to the gh-pages branch:
  • git checkout master
  • git push origin `git subtree split --prefix output gh-pages`:gh-pages --force

    Sweet line... uhh ;-)

  1. Finally, you will need to run the following line every time you want to update your site/blog!
  • git subtree push --prefix output origin gh-pages

Note: Are you getting git errors? Just use the sweet line again and force the update...

If you are using Nikola, you can add some of this lines to the DEPLOY_COMMANDS in your conf.py file and just run nikola deploy after building your site/blog.

More easier... impossible... ;-)

Damián.

UPDATE: Not enough happy with step 3 and 4 (essentially because of some git errors), I figured out a cleaner solution:

New 3. Now, we will use a git-subtree technique to push the build or output content to the gh-pages branch. You will need to run the following lines every time you want to update your site/blog!

  • git checkout master # you can avoid this line if you are in master...
  • git subtree split --prefix output -b gh-pages # create a local gh-pages branch containing the splitted output folder
  • git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
  • git branch -D gh-pages # delete the local gh-pages because you will need it: ref

Do you like the content? Great! Then help me to achieve a "Sustainable Crowdfunding"!

Comments powered by Disqus
Contents © 2014 Damian Avila - Powered by Nikola - Zen theme based in Arusahni's website-template
Creative Commons License BY-NC-SA