How to deploy only your dist folder to gh-pages branch (Github Pages)

In need of a positive encouragment?

Go to Positivity By Ray Ray and grow a positive mindset! ❤️

If you do a lot on Github, you probably know what Github Pages are. For the ones who don’t know: “On Github Pages you can host an HTML, CSS & JavaScript website. Simply create an branch called: gh-pages, wait a few minutes and you can find it with this url /github.io/“.

Only deploy your dist folder to Github Pages

When you’re working with a handy taskrunner like GruntJS or GulpJS, than you may have a dist folder where all files are in that are fully optimized. Grunt & Gulp have there own plugins to deploy to Github Pages:

But you can also create a simple Bat script (if your an windows user) or an Shell (if your an Mac user). The only code you have to add is:

    
        git subtree push --prefix dist origin gh-pages
    

If you think there is an faster way to deploy a dist folder to Github Pages, let me know in the comments!


Download the Bat & Shell script i created as an example. Hosted on Github.