{"id":13397534,"url":"https://github.com/wjdp/htmltest","last_synced_at":"2025-05-16T12:09:41.264Z","repository":{"id":13047938,"uuid":"71352821","full_name":"wjdp/htmltest","owner":"wjdp","description":":white_check_mark: Test generated HTML for problems","archived":false,"fork":false,"pushed_at":"2025-01-20T23:29:27.000Z","size":11349,"stargazers_count":341,"open_issues_count":78,"forks_count":54,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-09T20:06:48.933Z","etag":null,"topics":["cli-app","fast","golang","html-checker","html-linter","link-checker"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wjdp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-10-19T12:04:07.000Z","updated_at":"2025-04-30T09:02:28.000Z","dependencies_parsed_at":"2024-04-19T13:45:13.487Z","dependency_job_id":"1b992d58-2f38-483a-ad3a-e07bb5a6eeca","html_url":"https://github.com/wjdp/htmltest","commit_stats":{"total_commits":242,"total_committers":26,"mean_commits":9.307692307692308,"dds":"0.21900826446280997","last_synced_commit":"19a1f6f14818b23b4468d2f6ca7eef7b2c985642"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wjdp%2Fhtmltest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wjdp%2Fhtmltest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wjdp%2Fhtmltest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wjdp%2Fhtmltest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wjdp","download_url":"https://codeload.github.com/wjdp/htmltest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254527100,"owners_count":22085919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli-app","fast","golang","html-checker","html-linter","link-checker"],"created_at":"2024-07-30T18:01:29.227Z","updated_at":"2025-05-16T12:09:41.177Z","avatar_url":"https://github.com/wjdp.png","language":"HTML","readme":"# :white_check_mark: htmltest\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/wjdp/htmltest)](https://goreportcard.com/report/github.com/wjdp/htmltest)\n[![GoDoc](https://godoc.org/github.com/wjdp/htmltest?status.svg)](https://godoc.org/github.com/wjdp/htmltest)\n\nIf you generate HTML files, [html-proofer](https://github.com/gjtorikian/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.\n\n: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*.\n\n:horse_racing: *Faster?* Yep, quite a bit actually. On [a site](https://github.com/newtheatre/history-project) with over 2000 files htmlproofer took over [three minutes](https://travis-ci.org/newtheatre/history-project#L564), htmltest took [8.6 seconds](https://travis-ci.org/newtheatre/history-project#L538). Both tools had full valid caches.\n\n: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.\n\n## :floppy_disk: Installation\n\n### :penguin: Linux / :green_apple: macOS\n\nThis [godownloader](https://github.com/goreleaser/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.\n\n#### System-wide Install\n\n```bash\ncurl https://htmltest.wjdp.uk | sudo bash -s -- -b /usr/local/bin\n```\n\nYou'll be prompted for your password. After simply do `htmltest` to run.\n\n#### Into Current Directory\n\n```bash\ncurl https://htmltest.wjdp.uk | bash\n```\n\nBy default this will install `htmltest` into `./bin` of your current directory, to run do `bin/htmltest`. Rather suitable for CI environments.\n\n#### More options\n\nRun `curl https://htmltest.wjdp.uk | bash -s -- -h` for help text.\n\n### 📦 Package Repos\n\nWe're available in some [package repositories](https://repology.org/project/htmltest/versions) such as Homebrew and repos for certain distros. Do note the version available may not be the latest.\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/htmltest.svg)](https://repology.org/project/htmltest/versions)\n\n### ![win64](https://user-images.githubusercontent.com/1690934/30242799-17a573f2-9595-11e7-9aa5-04e34b04b0cd.png) Windows\n\n:arrow_down: Download the [latest binary release](https://github.com/wjdp/htmltest/releases/latest) and put it somewhere on your PATH.\n\n### :whale: Docker\n\n```docker run -v $(pwd):/test --rm wjdp/htmltest```\nMount your directory with html files into the container and test them.\n\nIf you need more arguments to the test run it like this:\n```docker run -v $(pwd):/test --rm wjdp/htmltest -l 3 -s```\n\n### 🧾 Temporary Files\n\nWe store temporary files in `tmp/.htmltest` by default. This contains a log of output and a cache of external links, speeding up subsequent runs. You probably want to ignore it in version control, and perhaps cache it in your CI system.\n\n## :computer: Usage\n\n```txt\nhtmltest - Test generated HTML for problems\n           https://github.com/wjdp/htmltest\n\nUsage:\n  htmltest [options] [\u003cpath\u003e]\n  htmltest -v --version\n  htmltest -h --help\n\nOptions:\n  \u003cpath\u003e                       Path to directory or file to test, if omitted we\n                               attempt to read from .htmltest.yml.\n  -c FILE, --conf FILE         Custom path to config file.\n  -h, --help                   Show this text.\n  -l LEVEL, --log-level LEVEL  Logging level, 0-3: debug, info, warning, error.\n  -s, --skip-external          Skip external link checks, may shorten execution\n                               time considerably.\n  -v, --version                Show version and build time.\n```\n\n## :microscope: What's Tested?\n\nMany options of the following tests can customised. Items marked :soon: are not checked yet, but will be *soon*.\n\n- `a` `link` `img` `script`: Whether internal links work / are valid.\n- `a`: Whether internal hashes work.\n- `a` `link` `img` `script`: Whether external links work.\n- `a`: :soon: Whether external hashes work.\n- `a` `link`: Whether external links use HTTPS.\n- `img`: Whether your images have valid alt attributes.\n- `link`: Whether pages have a valid favicon.\n- `meta`: Whether refresh tags are valid and the url works.\n- `meta`: :soon: Whether images and URLs in the OpenGraph metadata are valid.\n- `meta` `title`: :soon: Whether you've got the [recommended tags](https://support.google.com/webmasters/answer/79812?hl=en) in your head.\n- `DOCTYPE`: Whether a doctype is correctly specified.\n\n### What's Not\n\nI'd like to test the following but won't be for a while.\n\n- Whether your HTML markup is valid. htmlproofer has the ruby library [Nokogiri](http://www.nokogiri.org/tutorials/ensuring_well_formed_markup.html), I've not found one for Go yet.\n\n## :see_no_evil: Ignoring content\n\nAdd the `data-proofer-ignore` attribute to any tag or to the class of a tag to ignore it from every check. The name of this attribute can be customised.\n\n```html\n\u003ca href=\"http://notareallink\" data-proofer-ignore\u003eNot checked.\u003c/a\u003e\n```\n\n## :bookmark_tabs: Caching\n\nChecking 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.\n\n## :rainbow: Colour Output\n\nBy 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](https://no-color.org/).)\n\n## :fax: Logging\n\nIf 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.\n\n## :wrench: Configuration\n\nhtmltest 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.\n\n### Basic Options\n\n| Option | Description                                                                                                                                                                                                     | Default |\n| :----- |:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| :------ |\n| `DirectoryPath` | Directory to scan for HTML files.                                                                                                                                                                               | |\n| `DirectoryIndex` | The file to look for when linking to a directory.                                                                                                                                                               | `index.html` |\n| `FilePath` | Single file to test within `DirectoryPath`, omit to test all.                                                                                                                                                   | |\n| `FileExtension` | Extension of your HTML documents, includes the dot. If `FilePath` is set we use the extension from that.                                                                                                        | `.html` |\n| `CheckDoctype` | Enables checking the document type declaration.                                                                                                                                                                 | `true` |\n| `CheckAnchors` | Enables checking `\u003ca…` tags.                                                                                                                                                                                    | `true` |\n| `CheckLinks` | Enables checking `\u003clink…` tags.                                                                                                                                                                                 | `true` |\n| `CheckImages` | Enables checking `\u003cimg…` tags                                                                                                                                                                                   | `true` |\n| `CheckScripts` | Enables checking `\u003cscript…` tags.                                                                                                                                                                               | `true` |\n| `CheckMeta` | Enables checking `\u003cmeta…` tags.                                                                                                                                                                                 | `true` |\n| `CheckGeneric` | Enables other tags, see items marked with checkGeneric on the [tags wiki page](https://github.com/wjdp/htmltest/wiki/Tags).                                                                                     | `true` |\n| `CheckExternal` | Enables external reference checking; all tag types.                                                                                                                                                             | `true` |\n| `CheckInternal` | Enables internal reference checking; all tag types. When disabled will prevent internal hash checking unless the reference only contains a hash fragment (`#heading`) and therefore refers to the current page. | `true` |\n| `CheckInternalHash` | Enables internal hash/fragment checking.                                                                                                                                                                        | `true` |\n| `CheckMailto` | Enables–albeit quite basic–`mailto:` link checking.                                                                                                                                                             | `true` |\n| `CheckTel` | Enables–albeit quite basic–`tel:` link checking.                                                                                                                                                                | `true` |\n| `CheckFavicon` | Enables favicon checking, ensures every page has a favicon set.                                                                                                                                                 | `false` |\n| `CheckMetaRefresh` | Enables checking meta refresh tags.                                                                                                                                                                             | `true` |\n| `EnforceHTML5` | Fails when the doctype isn't `\u003c!DOCTYPE html\u003e`.                                                                                                                                                                 | `false` |\n| `EnforceHTTPS` | Fails when encountering an `http://` link. Useful to prevent mixed content errors when serving over HTTPS.                                                                                                      | `false` |\n| `IgnoreURLs` | Array of regexs of URLs to ignore.                                                                                                                                                                              | empty |\n| `IgnoreInternalURLs` | Array of strings of internal URLs to ignore. Exact matches only. ⚠ Likely to be deprecated, use `IgnoreURLs` instead.                                                                                           | empty |\n| `IgnoreHTTPS` | Array of regexs of URLs to ignore for `EnforceHTTPS`. These URLs are still tested, unless also present in `IgnoreURLs`.                                                                                         | empty |\n| `IgnoreDirs` | Array of regexs of directories to ignore when scanning for HTML files.                                                                                                                                          | empty |\n| `IgnoreInternalEmptyHash` | When true prevents raising an error for links with `href=\"#\"`.                                                                                                                                                  | `false` |\n| `IgnoreEmptyHref` | When true prevents raising an error for links with `href=\"\"`.                                                                                                                                                   | `false` |\n| `IgnoreCanonicalBrokenLinks` | When true produces a warning, rather than an error, for broken canonical links. When testing a site which isn't live yet or before publishing a new page canonical links will fail.                             | `true` |\n| `IgnoreExternalBrokenLinks` | When true produces a warning, rather than an error, for broken external links. Useful when testing a site having hundreds of external links.                                                                    | `false` |\n| `IgnoreAltMissing` | Turns off image alt attribute checking.                                                                                                                                                                         | `false` |\n| `IgnoreAltEmpty` | Allows `alt=\"\"` for decorative images.                                                                                                                                                                          | `false` |\n| `IgnoreDirectoryMissingTrailingSlash` | Turns off errors for links to directories without a trailing slash.                                                                                                                                             | `false` |\n| `IgnoreSSLVerify` | Turns off x509 errors for self-signed certificates.                                                                                                                                                             | `false` |\n| `IgnoreTagAttribute` | Specify the ignore attribute. All tags with this attribute or with this class will be excluded from every check.                                                                                                | `\"data-proofer-ignore\"` |\n| `HTTPHeaders` | Dictionary of headers to include in external requests                                                                                                                                                           | `{\"Range\":  \"bytes=0-0\", \"Accept\": \"*/*\"}` |\n| `TestFilesConcurrently` | :warning: :construction: *EXPERIMENTAL* Turns on [concurrent](https://github.com/wjdp/htmltest/wiki/Concurrency) checking of files.                                                                             | `false` |\n| `DocumentConcurrencyLimit` | Maximum number of documents to process at once.                                                                                                                                                                 | `128` |\n| `HTTPConcurrencyLimit` | Maximum number of open HTTP connections. If you raise this number ensure the `ExternalTimeout` is suitably raised.                                                                                              | `16` |\n| `LogLevel` | Logging level, 0-3: debug, info, warning, error.                                                                                                                                                                | `2` |\n| `LogSort` | How to sort/present issues. Can be `seq` for sequential output or `document` to group by document.                                                                                                              | `document` |\n| `ExternalTimeout` | Number of seconds to wait on an HTTP connection before failing.                                                                                                                                                 | `15` |\n| `RedirectLimit` | Allowed number of redirects. Use built-in behavior with negative values.                                                                                                                                        | `-1` |\n| `StripQueryString` | Enables stripping of query strings from external checks.                                                                                                                                                        | `true` |\n| `StripQueryExcludes` | List of URLs to disable query stripping on.                                                                                                                                                                     | `[\"fonts.googleapis.com\"]` |\n| `OutputDir` | Directory to store cache and log files in. Relative to executing directory.                                                                                                                                     | `tmp/.htmltest` |\n| `OutputCacheFile` | File within `OutputDir` to store reference cache.                                                                                                                                                               | `refcache.json` |\n| `OutputLogFile` | File within `OutputDir` to store last tests errors.                                                                                                                                                             | `htmltest.log` |\n| `CacheExpires` | Cache validity period, accepts [go.time duration strings](https://golang.org/pkg/time/#ParseDuration) (…\"m\", \"h\").                                                                                              | `336h` (two weeks) |\n\n### Example\n\n```yaml\nDirectoryPath: \"_site\"\nEnforceHTTPS: true\nIgnoreURLs:\n- \"example.com\"\n- \"^/misc/js/script.js$\"\nIgnoreDirs:\n- \"lib\"\nCacheExpires: \"6h\"\n```\n\n## :loudspeaker: Issues? Suggestions?\n\n[Submit an issue](https://github.com/wjdp/htmltest/issues/new).\n","funding_links":[],"categories":["Go","开源类库","HTML","Open source library","Quality Assurance","HTML Tester / Checker / Linter / Proofer"],"sub_categories":["测试","Test","Erlang"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwjdp%2Fhtmltest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwjdp%2Fhtmltest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwjdp%2Fhtmltest/lists"}