From 72cef9030644417b742f7f8c6780e7a6fd2e47c1 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Mon, 18 Oct 2021 20:16:21 +0100 Subject: [PATCH] Document how to adjust for a baseurl Fixes https://github.com/gjtorikian/html-proofer/issues/618 --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index a84aa958..8d221736 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,31 @@ Don't have or want a `Rakefile`? You can also do something like the following: htmlproofer --assume-extension ./_site ``` +#### Adjusting for a `baseurl` + +If your Jekyll site has a `baseurl` configured, you'll need to adjust the +generated url validation to cope with that. The easiest way is using the +`url_swap` option. + +For a `site.baseurl` value of `BASEURL`, here's what that looks like on the +command line: + +```bash +htmlproofer --assume-extension ./_site --url-swap '^/BASEURL/:/' +``` + +or in your `Rakefile` + +```ruby +require 'html-proofer' + +task :test do + sh "bundle exec jekyll build" + options = { :assume_extension => true, :url_swap => "^/BASEURL/:/" } + HTMLProofer.check_directory("./_site", options).run +end +``` + ### Using through Docker If you have trouble with (or don't want to) install Ruby/Nokogumbo, the command-line tool can be run through Docker. See [klakegg/html-proofer](https://hub.docker.com/r/klakegg/html-proofer) for more information.