Skip to main content

Check links for Markdown-based site

Project description

Linkchecker for Markdown-based static generated sites

Actions Status Language grade: Python pypi versions PyPi Download stats

Blazing-fast (10000 Markdown files per second) Python asyncio / aiohttp based simple check of links in Markdown .md files only. This tool is very helpful for large Markdown-based Jekyll and Hugo sites as well as Markdown-based MkDocs documentation projects. It is very fast and simple--it's what we use to check https://www.scivision.dev

Install

for latest release:

python -m pip install linkcheckmd

or for latest development version.

git clone https://github.com/scivision/linkchecker-markdown

pip install -e linkchecker-markdown

Usage

The static site generator does NOT have to be running for these tests--it looks at the .md files directly. The examples assume webpage Markdown files have top-level directory ~/web. If using the linkchecker on an MkDocs documentation project, Markdown files are typically found in a ~/docs directory.

Python code

import linkcheckmd as lc

lc.check_links("~/web")

Command-line

This program may be invoked by either:

linkcheckMarkdown

or

python -m linkcheckmd
  • Jekyll

    python -m linkcheckmd ~/web/_posts
    
  • Hugo

    python -m linkcheckmd ~/web/content
    
  • MkDocs Documentation

    python -m linkcheckmd ~/docs
    

The -v --verbose options prints the URLs as they are checked. Observe that URLs from different markdown files are interleaved, showing the asynchronous nature of this program.

Benchmark

For benchmarking and reference, we include a synchronous Requests-based method. For a website with 100+ pages, compare times of:

Git precommit

See ./examples/pre-commit script for a Git hook pre-commit Python script.

Tox and CI

This program can also be used as a check for bad links during continuous integration testing or when using tox.

Alternatives

Strict anti-leeching methods can cause false positives with this and other link checking programs.

Alternative solutions include:

  • asyncio-based web browser interface like Arsenic
  • Go-based htmltest.
  • GitHub Action for checking links in Markdown files.
  • Netlify link-check plugin
  • LinkChecker.py: too many false positives/negatives, very slow and only works with HTML.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linkcheckmd-1.3.0.tar.gz (9.8 kB view details)

Uploaded Source

File details

Details for the file linkcheckmd-1.3.0.tar.gz.

File metadata

  • Download URL: linkcheckmd-1.3.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.25.1 setuptools/47.3.1.post20200622 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for linkcheckmd-1.3.0.tar.gz
Algorithm Hash digest
SHA256 92bb79b8bf1f5225d9401ad021ec93ac6f17df3f9c7cb61b1618b95c99bc5a5a
MD5 e139327114caf8fb6ec64c38d20f1a4a
BLAKE2b-256 35d9ef2433652dc3f548dccf8f8e5c5d91083037da70116ece92479d12009d9f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page