I knew that in time it would be necessary to move this web to another address. The setup for deployment is its own hassle. The main things I wanted was to be able to come to an old address and get redirected to the correct current address. It would be quite easy with something dynamic, but these pages are static, and so cannot really catch someone attending a random address of the old page.

The structure of the new website should be identical so there is a simple way of doing it. Generate a single redirect page index.html for each of the previously active pages.

The code for a moved page was given to me by JJ ↗.

<!DOCTYPE html>
    <title>Page Moved</title>
    <meta http-equiv="refresh" content="0; URL=https://my.new.homepage.com/address" />
    This page has moved. Click <a href="https://my.new.homepage.com/address">here</a> to go to the new page.

For each old page we need to substitute address with the old address.

#!/usr/bin/env bash
for line in $(cat ./pages.txt); do
    par="$(dirname "$line")"
    mkdir -p "$par"
    echo "$par" "$line"
    echo "$pp"'/'
    cp orig.html copy.html
    sed -i 's|address|'"$pp"'|g' copy.html
    cp copy.html "$line"

Where the pages.txt contains list of all pages on your page – one per line. You may get it e.g. like this:

find . -iname "*.html" >pages.txt

Now the old pages redirect (and contain link) to their new counterpart.