HiD-BrokenLink

A broken link checker for the HiD static site framework.

After publishing, it scans the generated HTML, CSS and (optionally) JavaScript files and verifies that every local reference — links, images, stylesheets, scripts, inline url()s — points to a file that actually exists in the destination.

Requirements

Installation

cpanm byterazor::HiD::BrokenLink

Usage

Add +byterazor::HiD::BrokenLink to the plugins key in your HiD config. The + prefix tells HiD to use the full class name rather than looking in the HiD::Generator:: namespace:

plugins:
  - '+byterazor::HiD::BrokenLink'

The check runs after publishing and is enabled by default.

Configuration

| Key | Default | Description | | --- | --- | --- | | brokenlink.enabled | 1 | Run the check. | | brokenlink.check_html | 1 | Check href/src/data/poster attributes and inline <style> blocks in HTML files. | | brokenlink.check_css | 1 | Check url() references and @import statements in CSS files. | | brokenlink.check_js | 0 | Check quoted root-relative asset references in JavaScript files. | | brokenlink.strip_baseurl | 1 | Treat absolute URLs matching the site baseurl as local. | | brokenlink.exclude | — | Arrayref of regexes; matching references are not checked. | | brokenlink.report | — | Path of a text report listing the broken references, relative to the working directory (not the site destination). | | brokenlink.fail_on_broken | 0 | Fail the build when broken references are found. |

Examples

Basic

The plugin is enabled by default, no extra config is needed:

plugins:
  - '+byterazor::HiD::BrokenLink'
brokenlink:
  fail_on_broken: 1

Check JavaScript and write a report

brokenlink:
  check_js: 1
  report: _reports/brokenlinks.txt
  exclude:
    - '\.min\.js$'

License

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. See LICENSE.

Author

Dominik Meyer <dmeyer@federationhq.de>