Automatically check links on GitHub pages site

4/4/2017programming, tipsCody ReichertBack to blogs

I'm not good at checking my own code, and I've accidentally pushed broken links and bad HTML on numerous occasions. To solve this, I set up Assertible to automatically check the links and HTML on this blog every time I make a change.

Assertible has test assertions for checking links and HTML validation on a website. These assertions are perfect for this blog; it's a simple static site, heavy on content. I want to make sure that the links stay in tact and the markup is accessible.

The Assertible link checker assertion also checks <img>, <script>, <link>, etc tags in addition to <a> tags - so I get the free benefit of making sure all of the site's assets are available.

Automated checks and monitoring

First, I set up an hourly test schedule to run the assertions and notify me if anything fails. Failure alerts are sent to a Slack channel, and email.

But when you think about, it makes sense to check links immediately after every change to the site. Links may go bad over time, but by far the most common occurrence is when I'm pushing something new. Assertible's GitHub Deployments integration actually works out of the box with GitHub pages, so all I had to do was install the integration and create an environment called github-pages.

Now, every time I push to the master branch of this repository, GitHub deploys the site to GitHub Pages (automatically), sends a deployment event to Assertible, and Assertible then runs these smoke tests on the website. In addition, the tests are run hourly, and every failure will alert me over Slack or email. Cool, right?

:: @CodyReichert

Blog comments powered by Disqus.