Post

Miscellaneous

Jekyll

Check a Jekyll website for broken links and other issues with htmlproofer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function check-website {
  if [ "${1}" = "-h" ]; then
    echo "Usage: check-website [path]"
    echo "Check website with htmlproofer."
    return
  fi
  rm -rf Gemfile.lock _site .jekyll-cache && \
  docker run -it --rm \
    --volume="$PWD:/work" \
    ghcr.io/some-natalie/jekyll-in-a-can:latest /bin/sh -c \
    "bundle exec jekyll b -d '_site' && \
      bundle exec htmlproofer _site --disable-external \
      --check-html"
}

Build and run a Jekyll website in the current working directory, available at http://localhost:4000/. This script will clean up from the previous build if you pass -c as an argument.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function run-website {
  if [ "${1}" = "-h" ]; then
    echo "Usage: run-website"
    echo "Build and run the website in current working directory with Jekyll."
    echo "Website will be available at http://localhost:4000."
    return
  fi
  if [ "${1}" = "-c" ]; then
    echo "Cleaning up first ..."
    rm -rf Gemfile.lock _site .jekyll-cache
  fi
  docker run -it --rm \
    --volume="$PWD:/work" \
    -p 4000:4000 \
    ghcr.io/some-natalie/jekyll-in-a-can:latest
}
This post is licensed under CC BY 4.0 by the author.