Turn WordPress into a static site generator and host securely like Jamstack in a top cloud provider for free or at a very affordable cost.
Step 1: Install WordPress locally using your favorite method. I like localwp. I recommend keeping local files and databases in Git or iCloud/gdrive since we will not deploy database and WordPress source code. Alternatively, you can host WordPress in a cheap hosting for control-panel use only.
Step 2: Create static files of your WordPress site using a WordPress plugin called “Simply Static”. Install the plugin Simply Static and generate html static files.
Step 3: Now since I’m using localwp I need to replace local URLs with production URLs, and replace http
with https
.
create a Makefile
to help you replace URLs with the content below
LOCAL_URL := ashrafulabedein\.local
PRODUCTION_URL := www\.ashrafulabedein\.com
STATIC_FILE_DIR := $(shell pwd)/public
SED_COMMAND := find $(STATIC_FILE_DIR) -type f -exec sh -c
replace_http_with_https:
$(SED_COMMAND) "LC_ALL=C sed -i '' 's/https:/https:/g' {}" \;
replace_host:
$(SED_COMMAND) "LC_ALL=C sed -i '' 's/$(LOCAL_URL)/$(PRODUCTION_URL)/g' {}" \;
update LOCAL_URL and PRODUCTION_URL with your site URLs.
run make replace_http_with_https
and make replace_host
.
Step 4: Host static files on the cloud. Cloud options are
- Cloudflare Pages(free and paid plans)
- Netlify(free and paid plans)
- Amazon CloudFront(has Free Tier)
- Vercel(free plan for non-commercial projects)
Upload static files directly or connect the Github private repo to deploy automatically. I’m using Cloudflare Pages, which comes with all the goodness of Cloudflare security.
Step 5: Point your domain name to the cloud by updating DNS records in the domain control panel and that’s it! you have a high-performance and secure WordPress.