Package: mkdocs-htmlproofer-plugin
mkdocs-htmlproofer-pluginAMkDocsplugin that validates URLs, including anchors, in rendered html files.InstallationPrerequisitesPython >= 3.8MkDocs >= 1.4.0Install the package with pip:pipinstallmkdocs-htmlproofer-pluginEnable the plugin in yourmkdocs.yml:Note:If you have nopluginsentry in your config file yet, you'll likely also want to add thesearchplugin.
MkDocs enables it by default if there is nopluginsentry set, but now you have to enable it explicitly.plugins:-search-htmlprooferConfiguringenabledTrue by default, allows toggling whether the plugin is enabled.
Useful for local development where you may want faster build times.plugins:-htmlproofer:enabled:!ENV[ENABLED_HTMLPROOFER,True]Which enables you do disable the plugin locally using:exportENABLED_HTMLPROOFER=falsemkdocsserveraise_errorOptionally, you may raise an error and fail the build on first bad url status. Takes precedense overraise_error_after_finish.plugins:-htmlproofer:raise_error:Trueraise_error_after_finishOptionally, you may want to raise an error and fail the build on at least one bad url status after all links have been checked.plugins:-htmlproofer:raise_error_after_finish:Trueraise_error_excludesWhen specifyingraise_error: Trueorraise_error_after_finish: True, it is possible to ignore errors
for combinations of URLs and status codes withraise_error_excludes. Each URL supports unix style wildcards*,[],?, etc.plugins:-search-htmlproofer:raise_error:Trueraise_error_excludes:504:['https://www.mkdocs.org/']404:['https://github.com/manuzhang/*']400:['*']ignore_urlsAvoid validating the given list of URLs by ignoring them altogether. Each URL in the
list supports unix style wildcards*,[],?, etc.Unlikeraise_error_excludes, ignored URLs will not be fetched at all.plugins:-search-htmlproofer:raise_error:Trueignore_urls:-https://github.com/myprivateorg/*-https://app.dynamic-service-of-some-kind.io*warn_on_ignored_urlsLog a warning when ignoring URLs withignore_urlsoption. Defaults tofalse(no warning).plugins:-search-htmlproofer:raise_error:Trueignore_urls:-https://github.com/myprivateorg/*-https://app.dynamic-service-of-some-kind.io*warn_on_ignored_urls:truevalidate_external_urlsAvoids validating any external URLs (i.e those starting with http:// or https://).
This will be faster if you just want to validate local anchors, as it does not make any network requests.plugins:-htmlproofer:validate_external_urls:Falsevalidate_rendered_templateValidates the entire rendered template for each page - including the navigation, header, footer, etc.
This defaults to off because it is much slower and often redundant to repeat for every single page.plugins:-htmlproofer:validate_rendered_template:TrueCompatibility withattr_listextensionIf you need to manually specify anchors make use of theattr_listextensionin the markdown.
This can be useful for multilingual documentation to keep anchors as language neutral permalinks in all languages.A sample for a heading# Grüße {#greetings}(the slugified generated anchorGreis overwritten withgreetings).This also works for imagesthis is a nice image [](foo-bar.png){#nice-image}And generall for paragraphs:Listing: This is noteworthy.
{#paragraphanchor}ImprovingMore information about plugins in theMkDocs documentationAcknowledgementThis work is based on themkdocs-markdownextradata-pluginproject and theFinding and Fixing Website Link Rot with Python, BeautifulSoup and Requestsarticle.