My Profile Photo

Paul Brodner's Blog

Opinions are my own and not the views of my employer


Tips & Tricks


    Test my rendered html files with 'html-proofer'

    Now that I defined my static website, I need a way to test any changes that I will do in future. Here are the high level requirements that I want to cover: Test My Blog

    After a little research I found out that html-proofer is doing a good job so far.

    Configuring

    • I’m using Gemfiles to manage my gems, so:
      gem 'html-proofer', '~> 3.0', '>= 3.0.5'
      
    • Using Jekyll as framework my generated files are saved under _sites folder, so this command will actually run htmlproofer over my files, ignoring some predefined urls, hashtags or return code:
      $ bundle exec htmlproofer ./_site  --url-ignore '/#blog/,/paulbrodner.github.io/,/fb.me/' --http-status-ignore 999
      
    • After each commit, I want to automatically test my changes, so I’ve added Travis as my Continous Integration system.
    language: ruby
    rvm:
    - 2.4.1
    
    # I am using using bundler, therefore
    # the `install` step will run `bundle install` by default.
    script:
    - bundle exec jekyll build
    - bundle exec htmlproofer ./_site --disable-external --url-ignore '/#blog'
    
    
    # branch whitelist, only for GitHub Pages
    branches:
      only:
      - master
      
    env:
      global:
      - NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer
    
    sudo: false # route your build to the container-based infrastructure for a faster build
    
    

    In scripts section above, I first build my static website which is saved into “_sites” folder then I call htmlproofer on it to do his magic.

    Idea The entire source-code can be found on #10 merge-request

    Checkout also the current status in Travis: Build Status

    comments powered by Disqus