Non-official Docker image based on Dockerfile from fork of official GitHub Pages repo
358
From the currently empty local clone of a repo that is to be populated with the content of a GitHub Pages site, run
docker run --name gh-pages --rm -it \
--workdir /src/gh/pages-gem \
-v $(pwd):/src/site \
integrational/gh-pages \
bundle exec jekyll new /src/site
then strip-down Gemfile to
source "https://rubygems.org"
gem "github-pages", group: :jekyll_plugins
and strip-down _config.yml as follows:
description because it's taken from the GitHub repo automaticallybaseurl because it's set to /repo automaticallyurl because it's set to https://<org>.github.io (or similar) automaticallyThe content of this directory can now be pushed to GitHub to be served by GitHub Pages, as well as served/previewed locally as described next.
From the local clone of a repo that uses GitHub Pages, run
docker run --name gh-pages --rm -it \
-p 4000:4000 \
-v $(pwd):/src/site \
integrational/gh-pages \
bundle update && bundle exec jekyll serve
then browse to http://127.0.0.1:4000.
The above instructions remove baseurl from _config.yml because, when running in GitHub Pages, the jekyll-github-metadata plugin then sets it correctly. When serving the site locally, on the other hand, baseurl is left empty.
This post explains this approach and specifies how to construct links in the site content. In short:
{{ site.baseurl }}/path/to/css.css (separating /){{ site.baseurl }}{{ post.url }} (no separating /)The net result is that relative links work both locally and in GitHub Pages.
Content type
Image
Digest
Size
406 MB
Last updated
over 6 years ago
docker pull integrational/gh-pages