Verify changes on your website before publishing them

Publication date Read time 1 min Tags Linux / tutorial

Nice trick that lets you review changes done to website before publishing it.

I like static website generators. They are fast, secure, easy to tinker with and can be fully stored in version control system.

One neat thing they allow is ability to see changes before publishing them. The idea is to get two versions of website – before change and after change – and compare them automatically. Then it’s only matter of deciding if differences that you see are what you expected.

cd ~/path/to/website
make clean && make publish  # build the website
rsync -av $HOSTING:domains/ /tmp/live-website  # store live version in /tmp/
git diff --no-index /tmp/live-website/ ~/path/to/website/output/  # compare new and old

I usually run these commands when something in my build pipeline changes and I want to ensure it is backwards compatible. That’s why I first copy existing website back to disk instead of rebuilding it – so I can be sure my reference version is bit-by-bit identical with live version.