Need help with htmltest?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

wjdp
196 Stars 32 Forks MIT License 253 Commits 50 Opened issues

Description

:white_check_mark: Test generated HTML for problems

Services available

!
?

Need anything else?

Contributors list

# 168,747
golang
link-ch...
json-fo...
Node.js
168 commits
# 520,033
golang
link-ch...
conflue...
Markdow...
6 commits
# 130,935
Shell
link-ch...
xquery
hanami
5 commits
# 203,979
Shell
CSS
golang
link-ch...
4 commits
# 48,324
PHP
github-...
netlify
wordpre...
2 commits
# 1,998
Bootstr...
nix
Homebre...
travis
2 commits
# 12,441
C++
3d-poin...
c-plus-...
OpenCV
2 commits
# 65,082
hugo
netlify
gatsbyj...
gatsby
1 commit
# 62,491
golang
link-ch...
lambda
Neovim
1 commit
# 636,680
Shell
link-ch...
Erlang
HTML
1 commit
# 174,082
golang
link-ch...
Scala
Amazon ...
1 commit
# 208,525
aws-lam...
atom-fe...
Atom
js
1 commit
# 12,240
kafka
librdka...
SQL
kafka-c...
1 commit
# 423,626
The Jul...
Shell
generic
link-ch...
1 commit

:whitecheckmark: htmltest

Go Report Card GoDoc

If you generate HTML files, html-proofer might be the tool for you. If you can't be bothered with a Ruby environment or fancy something a bit faster, htmltest may be a better option.

:mag: htmltest runs your HTML output through a series of checks to ensure all your links, images, scripts references work, your alt tags are filled in, et cetera.

:horse_racing: Faster? Yep, quite a bit actually. On a site with over 2000 files htmlproofer took over three minutes, htmltest took 8.6 seconds. Both tools had full valid caches.

:confused: Why make another tool: A mix of frustration with using htmlproofer/Ruby on large sites and needing a good project to get to grips with Go.

:floppy_disk: Installation

:penguin: Linux / :green_apple: macOS / :iphone: Arm

This godownloader script will query GitHub for the latest release and download the correct binary for your platform into the directory set with the

-b
flag.

System-wide Install

curl https://htmltest.wjdp.uk | sudo bash -s -- -b /usr/local/bin

You'll be prompted for your password. After simply do

htmltest
to run.

Into Current Directory

curl https://htmltest.wjdp.uk | bash

By default this will install

htmltest
into
./bin
of your current directory, to run do
bin/htmltest
. Rather suitable for CI environments.

More options

Run

curl https://htmltest.wjdp.uk | bash -s -- -h
for help text.

win64 Windows

:arrow_down: Download the latest binary release and put it somewhere on your PATH.

:blowfish: OpenBSD

:arrow_down: Download the latest binary release and put it somewhere on your PATH.

You can also build from sources by cloning this repo and running

sh build.sh
, which puts the
htmltest
executable in the
./bin
dir. Use in place, or install to path such as
/usr/local/bin
.

fedora Fedora

htmltest is in the Fedora repositories, note this is not a first party build and may lag the latest version.

dnf install htmltest

:whale: Docker

docker run -v $(pwd):/test --rm wjdp/htmltest

Mount your directory with html files into the container and test them.

If you need more arguments to the test run it like this:

docker run -v $(pwd):/test --rm wjdp/htmltest -l 3 -s

Notes

We store temporary files in

tmp/.htmltest
by default. You probably want to ignore that in your version control system, and perhaps cache it in your CI system.

:computer: Usage

htmltest - Test generated HTML for problems
           https://github.com/wjdp/htmltest

Usage: htmltest [options] [] htmltest -v --version htmltest -h --help

Options: Path to directory or file to test, if omitted we attempt to read from .htmltest.yml. -c FILE, --conf FILE Custom path to config file. -h, --help Show this text. -l LEVEL, --log-level LEVEL Logging level, 0-3: debug, info, warning, error. -s, --skip-external Skip external link checks, may shorten execution time considerably. -v, --version Show version and build time.

:microscope: What's Tested?

Many options of the following tests can customised. Items marked :soon: are not checked yet, but will be soon.

  • a
    link
    img
    script
    : Whether internal links work / are valid.
  • a
    : Whether internal hashes work.
  • a
    link
    img
    script
    : Whether external links work.
  • a
    : :soon: Whether external hashes work.
  • a
    link
    : Whether external links use HTTPS.
  • img
    : Whether your images have valid alt attributes.
  • link
    : Whether pages have a valid favicon.
  • meta
    : Whether refresh tags are valid and the url works.
  • meta
    : :soon: Whether images and URLs in the OpenGraph metadata are valid.
  • meta
    title
    : :soon: Whether you've got the recommended tags in your head.
  • DOCTYPE
    : Whether a doctype is correctly specified.

What's Not

I'd like to test the following but won't be for a while.

  • Whether your HTML markup is valid. htmlproofer has the ruby library Nokogiri, I've not found one for Go yet.

:seenoevil: Ignoring content

Add the

data-proofer-ignore
attribute to any tag to ignore it from every check. The name of this attribute can be customised.
Not checked.

:bookmark_tabs: Caching

Checking external URLs can slow tests down and potentially annoy the URL's host. htmltest caches the status code of checked external URLs and stores this cache between runs. We write the cache to

tmp/.htmltest/refcache.json
and expire items after two weeks by default.

:rainbow: Colour Output

By default, output in the TTY uses colours to indicate warnings, errors, and success. To turn off colourization, set an environment variable named

NO_COLOR
. If it is present, no colour will be used. The value is ignored. (See no-color.org.)

:fax: Logging

If you've got a lot of errors, reading them off a TTY may be difficult. We write errors to

tmp/.htmltest/htmltest.log
by default. The log level is set in the config file.

:wrench: Configuration

htmltest uses a YAML configuration file. Put

.htmltest.yml
in the same directory that you're running the tool from and you can just say
htmltest
to run your tests. You'll probably also want to cache the
tmp/.htmltest
directory.

Basic Options

| Option | Description | Default | | :----- | :---------- | :------ | |

DirectoryPath
| Directory to scan for HTML files. | | |
DirectoryIndex
| The file to look for when linking to a directory. |
index.html
| |
FilePath
| Single file to test within
DirectoryPath
, omit to test all. | | |
FileExtension
| Extension of your HTML documents, includes the dot. If
FilePath
is set we use the extension from that. |
.html
| |
CheckDoctype
| Enables checking the document type declaration. |
true
| |
CheckAnchors
| Enables checking
 tags. | 
true
| |
CheckLinks
| Enables checking
 tags. | 
true
| |
CheckImages
| Enables checking
 tags | 
true
| |
CheckScripts
| Enables checking

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.