ubbn
8/25/2017 - 9:35 AM

Note Series: Jekyll

Note Series: Jekyll

# Install docker on snap
snap install docker

# Get docker image of jekyll
docker pull jekyll/jekyll

# Generate new blog on in dir myblog ported to docker container
export JEKYLL_VERSION=latest
docker run --rm --volume="$PWD:/srv/jekyll" -it jekyll/jekyll:$JEKYLL_VERSION jekyll new myblog

# Build the site installing gems etc.
cd myblog
docker run --rm --volume="$PWD:/srv/jekyll" -it jekyll/jekyll:$JEKYLL_VERSION jekyll build

# Serve the blog (--name here is optional, if missed, random crazy name will be given)
docker run --name myblog-container --volume="$PWD:/srv/jekyll" -p 4000:4000 -it jekyll/jekyll:$JEKYLL_VERSION jekyll serve --watch --drafts

# Executing command in container
docker exec -ti myblog-container /bin/sh
# Install jekyll theme in container
docker exec -ti myblog-container gem install "jekyll-theme-hydeout"

# Manage container state by its name
docker start myblog-container 
docker restart myblog-container
docker stop myblog-container

# Remove container
docker rm -f myblog-containerdo


# Delete all historical containers
for d in `docker ps -aq`; do docker rm $d ; done

Installation

# Some packages are not found in standard repository of linux. So first enable optional repository
# To enable first you need the name. I used grep to do this:
sudo grep -B1 -i optional /etc/yum.repos.d/*
# Enable the optional repo:
sudo yum-config-manager --enable <repo-id>
# Refresh the yum cache (not sure if this is necessary but it doesn't hurt):
sudo yum makecache


# Install or upgrade ruby, to do that, better to use ruby version manager tool: 
# If any problem, follow guideline from rvm offical website
sudo gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | sudo bash -s stable
sudo usermod -a -G rvm `whoami`

# Install or upgrade ruby
rvm install ruby

# install ruby development package
sudo dnf install ruby-devel

# Install ruby gem
sudo dnf install rubygems

# Necessary package for jekyll
sudo dnf install redhat-rpm-config

# Install gems
gem install bundler
gem install jekyll



Jekyll note

Concepts

Any config can be either specified in config file _config.yml or specified as flags on command line

Configuration

source: .
destination: ./_site

Some commands

Generate new static site
jekyll new <site-name>
Start server accessible to all ips (and detachable from terminal)
jekyll serve --host 0.0.0.0 --detach