WordPress plugins such as the Simply Static and others have the ability to automatically convert each of the WordPress pages and posts into static HTML files.
I tried it in my environment but without any convincing result: When I double checked, the exported pages did still contain URLs which were pointing to the server, so on first sight everything seemed to work, but if you switch off WordPress the exported files stopped to work as well!

I wanted to have a more reliable way to dump a whole WordPress Site w/o having to pay for any unnecessary service and indeed there is an easy solution by just using wget which is available on all Linux or OS/X distributions.

I used the following command:

wget -nd -r -k -E  --base=https://www.pschatzmann.ch  https://www.pschatzmann.ch/home/

  • nd makes sure that all files are created in one single directory (with no subdirectories!)
  • r recursive (downloads the index and all related files)
  • k is converting the links (to point to the local files) after the download has completed
  • E saves HTML/CSS documents with proper extensions
  • base is indicating the base URL which needs to be removed to make sure that all links are relative
  • https://www.pschatzmann.ch/home/ is the URL to the start page of the website which needs to be downloaded

The whole website is downloaded and occupies only 41M Bytes.

You can now make sure that your Webserver is pointing to the exported directory and then you have your working static Website that looks like your WordPress Site!

This is pretty trivial e.g. with Docker and NGINX:

docker run -v /Users/pschatzmann/Downloads/x/www.pschatzmann.ch:/usr/share/nginx/html:ro -d -p80:80 nginx

where
-p80:80 makes the server available on port 80
-d runs the server as demon (in the background)
/Users/pschatzmann/Downloads/x/www.pschatzmann.ch is the downloaded directory which contains the index.html


0 Comments

Leave a Reply

Your email address will not be published.