- Ruby
- GitHub
- GitHub Pages
- GitHub Actions
- Jekyll
- Jekyll theme, Just-The-Docs
GitHub Pages supports Jekyll by default. GitHub has gone so far as to make this process easy by allowing you to deploy sites without a Gemfile to list dependencies. For me, this was a difficult process, where my local Gem dependencies were different than the Pages server. This difference in dependencies makes testing and quality-assurance difficult, especially since GitHub Pages only gives you website instance, deployed from your main branch (this repository's main branch is production and was configured in the Settings panel of GitHub).
Some frequent issues during testing:
- differences between the Jekyll themes (Local versus Remote)
- links, tags, and includes working well locally, but do not complete on GitHub pages (Liquid/Jekyll path issues)
- HTML and CSS customizations building as intended locally, but causeing issues on GitHub Pages
GitHub runs a GitHub-Action whenever it sees new commits on the main branch.
This Action will review _config.yml, and will deploy all your .md and .html files.
GitHub Pages lets you choose to host your files from the project's root directory /
or from a docs folder /docs
.
I chose the root directory, since I wanted to also test the site locally on my computer.
Ruby uses your project's Gemfile as a package manager.
When you run bundle install
from the root of the project directory, Ruby will read your Gemfile and install all the Gems (dependencies) listed in it.
Running bundle update
is similar, but comparing the current state of you project's Gemfile.lock to the Gemfile and installing or removing files based on the differences.
Note that the .gitignore for this project prevents the Gemfile.lock from being added to GitHub, so it is a new installation every time a User clones the repository.
This is okay for our use case with GitHub Pages as our deployment server,
since Pages does not reference the repository's Gemfile.lock for CI/CD (Continuous-Integration/Continuous-Deployment).
After running bundle install
, you can start the server by running the command:
bundle exec jekyll serve --config _config_local.yml --livereload
This command has 3 main aspects:
bundle exec jekyll serve
will deploy the website using Jekyll, which was an installed dependency in the Gemfile--config _config_local.yml
is telling Jekyll to use the configuration file _config_local.yml in the root of the project directory. Omitting this aspect of the command would have Jekyll use the default file, _config.yml. The default file has been configured for GitHub Pages, and causes issues for local deployments.--livereload
tells Jekyll to redeploy the website every time the project is updated. This includes any new file, updating an existing file, or changing the directory folder structure. Note that this automatic redeployment does not capture changes to _config_local.yml, so you will need to manually restart the server if you make changes to the configuration.
After running the command, you can access the website in a web-browser like Google Chrome at the address http://127.0.0.1:4000
-
Set up your GitHub account.
-
Install Git on your computer.
- Go to the Git website https://git-scm.com/download/win and select the Click here to download button for the latest version.
- Run through the installer.
-
Set up the Ruby programming lanuguage on your computer
- Open a terminal, and enter
ruby -v
. You will receive an error messge if you do not have the Ruby interpretter installed on this Windows machine. - To install Ruby on Windows, got to https://rubyinstaller.org/downloads/ and download Ruby+Devkit 3.1.2-1 (x64) or a newer version.
- Open a terminal, and enter
-
Set up VS Code as your text editor
-
Go to https://code.visualstudio.com/download and select the Windows download.
-
Open the .exe installer, and go through the installation instructions
-
Launch VS Code after it has been installed. The welcome screen will likely ask you what programming extensions you want to use. You can skip this for now.
-
From the homescreen, click extensions.
-
Search for Ruby, and click the Install icon beside the extension.
-
Search for Prettier, and click the Install icon beside the extension.
-
Search for Live Server, and click the Install icon beside the extension.
-
Search for Git Lens, and click the Install icon beside the extension.
-
Open a new terminal in VS Code, and enter
ruby -v
.Close and re-open VS Code if you get an error message.
You should get a confirmation message indicating the version of Ruby.
-
In the same terminal, enter
gem -v
You should get a confirmation message indicating the version of Ruby Gems.
-
Now configure your Git settings in the same terminal.
- Enter
git config --global user.name <"Your name goes here in quotes">
- And enter
git config --global user.email <Your email goes here>
For example, my Git settings look like this:
git config --global user.name "Rhys Faultless" git config --global user.email rfaultless@clearpathrobotics.com
- Enter
-
-
Clone this repository to your computer.
-
Open a terminal in VS Code.
-
Use cd and cd .. to navigate to the directory you want to store GitHub repositories locally on your computer. I save mine to the directory
C:\Users\rfaultless\Documents\Github
. -
Now clone this repository to your computer by entering:
git clone https://github.com/rhysfaultless-cpr/cpr-documentation-jekyll.git
-
Once the command is finished running, enter ls in the terminal. You should see a new folder named cpr-documentation-jekyll
-
In VS Code, click File and select Open Folder ...
-
In the window, navigate to the cloned directory cpr-documentation-jekyll and then click Select Folder
-
-
Testing the Documentation server on your computer.
-
Open a terminal in VS Code.
-
Make sure your terminal session is directed to the root directory of the project, such as:
C:\Users\rfaultless\Documents\Github\cpr-documentation-jekyll>
-
In the termainal session, enter:
bundle install
This will install all the project dependencies listed in the Ruby file Gemfile. You will see new files and folders appearing in the project directory, like:
- Gemfile.lock
- _site
-
After the files are installed, enter this in the terminal session:
bundle exec jekyll serve --config _config_local.yml --livereload
This will start a server on your local computer for hosting the Documentation website. Windows Defender may show a pop-up asking if it should allow this application port permissions for Public, Home, or Work networks. After ~5 seconds, the terminal will show:
Jekyll Feed : Generating feed for posts GitHub Metadata : No GitHub API authentication could be found. Some fields may be missing or have incorrect data. done in 10.315 seconds. Auto-regeneration : enabled for 'C:/Users/rfaultless/Documents/Github/cpr-documentation-jekyll' LiveReload address : http://127.0.0.1:35729 Server address : http://127.0.0.1:4000/ Server running... press ctrl-c to stop.
-
You can now access the Documentation website by opening a web-browser like Google Chrome, and entering the URL: http://127.0.0.1:4000
-