loading words...

Jun 26, 2019 20:45:44

Migrating Off WordPress

by @valentino | 295 words | 60🔥 | 358💌

Valentino Urbano

Current day streak: 60🔥
Total posts: 358💌
Total words: 170604 (682 pages 📄)

*This is a continuation of my series on migrating my web site off WordPress and onto Jekyll

Automatic Testing After Each Commit

If your website is open source (let's say on a Github repository as we set it up here for simplicity) you can add a trigger to make Travis (a suite of automated tools to test your application) build every commit that you push to the repository and test the HTML generated with htmlproof.

First, you'll need to add a file called .travis.yml at the root of your website:

language: ruby
  - 2.2
  - bundle exec jekyll build
  - bundle exec htmlproof ./_site --only-4xx
    - NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer

bundle exec jekyll build builds your website and generates the /_site folder with all the output.
bundle exec htmlproof ./_site --only-4xx checks the images in your site (including if they contain an alt tag or not) and checks all the links, returning an error only if the link is a 4** so it doesn't return an error if it's a temporary error or a server issue.

Commit the file and head to Travis. If your project is open source you won't have to pay anything since Travis is free for open source projects. Allow access for your account. Travis will start by scanning all your repositories, once finished you can tick off the repository with your site that you want to test. Each time you push a commit or there is a pull request to that specific branch (usually master) Travis will build your site and make sure there are no errors. If there is any error it will show the error message directly in Github.

After doing this it's recommended that you always make a branch a do a pull request back to master every time you change something instead of pushing the change to master directly so that you let your test run before merging it into the master branch that gets built by Github Pages.

contact: email - twitter / Terms / Privacy