Starting a GitHub Pages site from scratch
I wanted to start my own GitHub Pages site from scratch. In particular, I really want to be able to develop and test the site locally and push to GitHub only, if new contributions have been tested on my local machine.
To start a jekyll-based site on GitHub pages from scratch, I have oriented myself along the instructions in the GitHub documentstion. Yet, some details were missing or confusing (at least to me).
Here are the steps, that work for me:
-
Navigate to the parent directory, in which you want to create the folder to store the website repository
cd <parentDirectory>
-
Create an empty
git
repository for the website:git init <GitHubUserName>.github.io
- Create an emtpy jekyll-based site via
jekyll new .
. - Open the auto-generated Gemfile
- Follow the instructions in the Gemfile’s comments to use GitHub Pages.
- Update the
gem "github-pages"
line so that the line looks like this, replacing<version>
with the current dependency version forgithub-pages
.
gem "github-pages", "~> <version>", group: :jekyll_plugins
For more information, see Dependency versions on the GitHub Pages site.
- Close the
Gemfile
.
- Remove the auto-generated
Gemfile.lock
viarm Gemfile.lock
. Otherwise, the next step failed with inconsistencies in version numbers of various components defined in theGemfile
. - Run
bundle install
.
The jekyll setup is now finished and you can start do develop your site.
To preview the site on your local machine, run bundle exec jekyll serve
and use a brownser to navigate to the Server address:
,
that has been printed in the terminal.
As your site is wrapped into a regular git
repository, remember to commit your changes.
Once you’re ready to publish the site, commit everything and push to GitHub via:
- Create a repository with the name
<GitHubUserName>.github.io
on GitHub. - Set the new repository as remote on your local repository.
- Push your local repository to GitHub.
Now, you can view your published site at https://<GitHubUserName>.github.io
.
It might take a minute or two for jekyll to actually generate your site, so be patient.
The results will be worth it!