TL;DR: I built my static personal site (https://sebagomez.github.io/) using a container instead of installing all the needed runtime/build for Jekyll which includes Ruby and who knows what else.
I came across a very cool personal site lately (https://jarrekk.github.io/Jalpc/) and I thought it was time to revamp my old GitHub Page with something useful. The repo of the site was hosted on GitHub so I thought I could just fork the repo myself and update it with my data. WRONG!
After forking the repo I realized it was something called Jekyll. I had heard about Jekyll before but had no idea what it was, less how to use it. I started to read a little about it to find out I had to install Ruby. Don’t get me wrong, I have nothing against Ruby, but I don’t want to install anything else on my PC. Especially another runtime/build tools.
So before deleting the project and forget all about the site, I thought I could spend 2minutes looking for a container with the needed tools. Lucky me! I found the right container (jekyll\jekyll:builder).
So this is what I did to get my site without knowing anything Jekyl (or Ruby).
The first thing I did was to start a container based on that image, I noticed that `jekyll serve` starts a web server in port 4000 so I added the -p flag and the -v to mount my files inside the container. This is the command I ran:
docker run — rm -v c:/code/sebastian/Jalpc:/srv/jekyll -p 4000:4000 -it jekyll/jekyll:builder bash
I created a batch file that fires up the container.
Once inside the container in the bash prompt you could just type `jekyll serve`. This command will build the static site and fire up a web browser to it on port 4000.
And that’s it. That’s how you build the site, but now you’ll have to push it to your <username>.github.io repository, so this is my solution… it might be a better one I’m not aware of, so this is what I did.
The generated static site is located under the _site folder, so I created another batch file called deploy.cmd that does exactly that… it’ll copy the files under _site to another repo in my local machine that has a remote against my sebagomez.github.io repo
robocopy _site\ ..\github.io *.* /E /XF *.cmd *.md
After everything is copied, all I need to do is go to the github.io repo and commit/push the changes.
Why did I do it that way?
The problem is the _site folder is ignored in the original repo, and of course, we want to keep it that way. And there’s no (known by me) way of adding another remote repo with a different .gitignore file, so I didn’t know how to solve that. This is the best solution I could come up with, I’m open to suggestions on how to improve this design.