HTML Tidy on Netlify
I wanted to use HTML Tidy as part of the build process for a static site hosted on Netlify.
The solution was to include the HTML Tidy binary as part of the repo and then call it as part of the build script.
The HTML5 Tidy binaries can be found here.
The Netlify build environment runs Ubuntu with x86_64 architecture, so I downloaded the latest
.deb file with description “linux 64-bit DEB”.
A debian package is an
ar archive which can be extracted with:
ar -x tidy-5.4.0-64bit.deb
Now extract the files from the
tar -xzf data.tar.gz
The HTML Tidy binary is the file at
This is the file that I copied into the static site repo within the
I could now reference the
bin/tidy binary as part of the Netlify build process.
eg. in a Makefile:
dist/%.html: html/%.html bin/tidy -config tidy-config.txt $^ > $@
I needed to tweak this slightly so that I could still build the site on my local machine:
UNAME := $(shell uname) ifeq ($(UNAME), Darwin) TIDY = /usr/local/bin/tidy else TIDY = bin/tidy endif dist/%.html: html/%.html $(TIDY) -config tidy-config.txt $^ > $@
Now my local machine will use the HTML Tidy that was installed with homebrew at
/usr/local/bin/tidy, and the Netlify build will use the bundled binary in