A while ago, my first blog entry was about my thoughts for setting up my Blogging environment. Since I wrote that post, I went down different paths and tried out some setups. This is what I ended up with and how I got there.
My first attempt was to use WordPress in my local network to write the content. Using WP2Static, a static website WordPress plugin, I was able to push a static version of that page to Github Pages, since I do not want to go trough the pain of running WordPress publicly on the web. I then setup a redirect from my homepage to that Github Pages page (since FTP export from WP2Static did not work with my hoster). As a bonus, my dev.to profile grabs the static RSS feed to syndicate those posts. But I wanted more!
There were some problems with that attempt. First, WP2Static puts every single resource from my static website into it’s own commit. This makes it very hard to build a CD pipeline on top of Github, because every file would trigger a new pipeline run. A permanent 301 from my website to Github is not the best solution as well.
To round things off, I didn’t find a proper way to syndicate the posts beyond dev.to. Ideally, it would also be available on Medium, LinkedIn or Xing if I chose to.
The first problem I wanted to tackle was to circumvent the messy way WP2Static handles the Github export. For my pet projects I already used a local Gitlab, which is also supported by WP2Static, so I just tried exporting the page to that. But I soon discovered that WP2Static expects you to use the cloud version of Gitlab, not a local instance. But I managed to solve this with a quick search&replace, replacing the Gitlab cloud URL with the local instance’s URL. And voilà: It uses a single commit and nicely pushes everything into the repo.
Once I had everything in that repo, I quickly setup a CD pipeline with a Gitlab runner. That pipeline connects to my website via FTP (lftp to be specific) and places the resources from the repo there. This pipeline runs on the branch that WP2Static puts the static export. So every time I run the export, it get’s published on my website automatically. Through the RSS feed, dev.to get’s serviced as well.
To take care of the further syndication, I use a WordPress plugin called Blog2Social, which connects to the different social networks and publishes the post there. It also allows me to choose where and when I want to put up a post.
So for now, I consider this project done. This is how my publishing process looks like:
- Write a post on WordPress locally
- Start the static export with WP2Static, making the post available on my website and dev.to
- Use Blog2Social in WordPress to push the post to other social networks
- Change the visibility of the post to public on dev.to, since it doesn’t autopublish posts gathered via RSS. (Maybe this could be changed to use Medium as a source?)
So, what do you think about this setup? Did I overlook any obvious way this could be done in an easier way?