Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publishing to github pages without versioning artifacts?

Is there a way to publish to the gh-pages branch of a project without versioning generated css/js in that branch?

For example, here is the gh-pages branch version history of a generated css file, desktop.css. It seems that every time the scss files are changed and committed, the desktop.css file is also regenerated and committed. That seems unnecessary to store.

I am thinking of the parallel in projects that use css preprocessors like Sass or Javascript bundlers. We typically don't version the generated code since it just repeats data we already have (the precompiled/prebundled code). If we wanted to go back to an earlier version, we would restore an older version of the Sass, for example, and regenerate the css from there. The same should be said for regenerating an earlier version of a gh-pages page, no? Also there's the issue of unnecessary artifacts and bloat to the repository from these generated files.

Is there a workaround that can have the building of the code happen without versioning generated css/js? One possibility I thought was about purging and re-branching the gh-pages branch each time I need to regenerate but that seems extreme. I sometimes wonder if Github should offer gh-pages as a tag as well as a branch so that we can move that tag to point to a different commit whenever we need Travis CI or what have you to regenerate.

How are others addressing this? Or is it just not a big deal?

Update Thu Dec 18 19:28:16 EST 2014

David gave a nice answer below that is Jekyll specific, demonstrating a jekyll site with just scss but whose hosted github page was built with generated css. It seems the magic is in the _config.yml file. While I like the answer (and upvoted it), it does not address the general case.

For now I think I will go with a periodic git purge approach. I will deploy to the gh-pages branch, letting it version the generated css/js. Then every once in a while, if i feel the repo has gotten too bloated, I will just empty the branch with git filter-branch commands as explained by Github or just delete it locally and remotely and recreate it. That way, I get the flexibility of using whatever static site generator I want, adjusting and generating as much as I need, and keeping repo size manageable. At the price of an extra few steps.

like image 380
yuvilio Avatar asked Nov 20 '25 04:11

yuvilio


1 Answers

You can have a look at Jekyll the static site generator supported by Github page. Natively use sass and version only source files. Clean !

like image 148
David Jacquel Avatar answered Nov 22 '25 21:11

David Jacquel