Creating a Publii Site on Digital Ocean

Since I converted over to Publii from Wordpress recently, I figured now was a good time to do a quick little write up on how I went about it. It could be much more cheaply and easily done than what I did with most "simple hosting" providers, but for $6 per month I can use a simple Digital Ocean Droplet, with automated backups, which I can maintain full control of the system, so it's worth it to me.

First off, it's worth mentioning I had a Digital Ocean hosted Wordpress blog running on an Ubuntu Server 18.04 Droplet (was original 16.04 but upgraded at some point). I did a manual backup as well as a Wordpress Export (using it's built in Export tool) during the transition to bring data over. Beyond the pre-existing Digital Ocean account, a Wordpress export in hand, and a pre-existing domain I could just point at a new server, there wasn't much else needed. If you're starting fresh you'll need a bit of that, but I'll try to call it out as we're going.

Why Publii?

I've used Wordpress for a few years and I like it plenty but it feels like a huge amount of overkill for my needs. Publii is a simple single app you download, there's no web-based management, and it generates and uploads a static site to your host, so it's really easy to just play with, see if you like it, and then publish if you do. It's more secure in that there's just one less vector for an attacker to hit since there's no web-based management. The overall software and performance requirements on the server are ridiculously lower than Wordpress, too. I did look at a number of other static site generators, and while there are a lot of neat ones, Publii's desktop app includes easy management tools, a WYIWYG editor, and other "it's just simple" features is a no brainer for me. I didn't see any others that are as or more popular than Publii that make it so easy. If you need something easy, quick, and simple, give Publii a look.

Basic Publii Setup

Getting Publii setup itself is very easy. Simply go to the Publii downloads page, download it, install it if necessary, etc. I'm using Ubuntu Desktop so I just downloaded the AppImage version, did a quick chmod +x on it, and ran it. Initial setup once running is easy. It asks you make a site, you give it a name and set your Author Name, and you're rolling.

Once you're setup, a few tips I think are worth sharing.

  • Something that threw me off when first setting up was finding all the settings for things. It took a little while to get the layout to look how I wanted by jumping around between site and theme settings. Once I bounced around through every setting it made sense, but it took a little bit of "where is this?" followed by "oh, I guess that makes sense." In other words, really dig through the settings to get an idea of things.
  • Take a look at the Publii Marketplace, and grab a few themes you think will probably work. You can tweak quite a bit from the Publii settings, and having options to swap between while deciding on a final result helps. When you switch you'll probably need to reformat some things, so use the preview option regularly to figure out what's changed. Once you've landed on one it's a bit awkward but you can just "uninstall" the others.
  • Adding a menu is simpler than it appears at first glance. I'm used to having Posts and Pages be separate things. In Publii, they're the same thing. When you create a menu, you select Posts you've made, which effectively makes them Pages. Just a bit of a distinction that took me a minute or two to wrap my head around.

Otherwise, you can poke around, makes some posts, get things together. I recommend using the full site preview regularly to keep a feel of how things will work in the end result. Also, mini-protip, in Chrome's developer menu (hit the F12 key to bring it up), hit the icon in the top left that looks like a cellphone over a tablet to get an idea of what the site looks like on a phone.

I did import my old Wordpress content so I could get an idea of what the themes looked like. I still have all that content here, I just hid the majority of it and only turned on enough so my JayP-NAS 2.0 documentation and scripts could be accessed still. I like the way content hiding works here, it's easy to just stick something away so it's not cluttering your blog posts but still be able to get to it as a page that way.

Getting a VPS/VM/Host Setup

There are a lot of options here. Publii itself can be setup to point to AWS, GitHub/GitLab, Google Cloud, Netlify, FTP, or SFTP pretty easily. Like I said earlier, I set up mine in a Digital Ocean Droplet because I prefer it. There are tons of great VPS providers, and given that Publii supports FTP and SFTP I imagine it works wonderfully with a lot of simple hosting providers, too.

When creating my Droplet I went for the absolute lowest end Droplet you can make, and picked Ubuntu Server 20.04 because I'm used to it. As Publii is a pretty simple static site generator, you need incredibly little performance for it to run, and it's all dependent on what your traffic is like. My site doesn't draw much so I don't see any reason to do anything more than the lowest end. To explain a bit better, since I launched it my 1vCPU, 1GB Droplet has barely scrapped 5% CPU and 30% RAM usage since I launched it, and when it does scrape those numbers it's when I'm doing an apt update && apt upgrade cycle. I also added the backups option during creation for peace of mind. Once things are up and running for good, it's easy to roll the site back a bit if you futz something up.

In regard to the server's software setup (for anyone using a VPS provider), all you really need is SSH, a web server (I prefer Nginx), and a domain name to point at the VPS. Digital Ocean has fantastic documentation for their basic setups. Here's what I used:

Note, while setting up Let's Encrypt, your domain needs to be pointing at your server. When I was moving the site between Droplets I left the old site up during the transition and just went to my registrar to point domain to the new server. I used a quick DNS propagation checker (such as to confirm things were moved over before starting the Let's Encrypt portion.

A quick little aside, if you setup something very similar to what I've done, I have a really simple little shell script for Ubuntu systems to check for updates and let you know if the system needs to reboot. It just echo's out little warnings of what's happening, does the apt commands, and the if loop checks to see if a certain file exists. if it does, it warns you to reboot, if not, you're good. I believe this should work any Debian system.

echo '#########################'
echo '# Performing apt update #'
echo '#########################'
sudo apt update
echo '##########################'
echo '# Performing apt upgrade #'
echo '##########################'
sudo apt upgrade
echo '#########################'
echo '# Do we need to reboot? #'
echo '#########################'
if [ -f /var/run/reboot-required ];
  echo 'Yup, you should reboot.'
  echo "Nope, you're good."

I just make a file named in my home directory, copy/paste that in it, chmod +x it, and run it every so often. A lot of sysadmins are very cautious about performing system updates "too frequently" due to incompatibilities. I find that 9 times out of 10 those incompatibilities are created by sysadmins, though. Some goofy configuration they setup, some weird hyper specific cronjob'd perl script, etc. If you keep a system as bare-bones and simple as possible, such as we're doing with this, frequent updates just means you're as secure as you can be.

Setting up Publii to point at the server

Publii's documentation for setting up the server is simple enough to follow. I will note, if you can help it don't use FTP. If you run the server and setup SSH, you already can do SFTP without needing to install anything else. If you're using a simple hosting provider that needs to use FTP... find a different provider. FTP is a perfectly fine protocol but it's ancient at this point, unsecure, and there are so many better options.

Once it's been setup, you can sync your site... and you're done.

Concerns going forward

The biggest concern I have with Publii doesn't effect me but could be a problem for others: Sync'ing your site between authors. Publii suggests something like Dropbox... I didn't read into it super far but I guess the idea is you point your Publii app at a folder in Dropbox (I'd use Nextcloud since I have a Nextcloud VM but whatever you want to use), share that folder among your authors, and that's kind of it. Even though that sounds plausible it also sounds like it could be a massive headache with not that many authors. Conflicting copies will happen at some point, I imagine.

It also looks like Publii is developed by a small-ish team, but they have fairly frequent updates. If at some point they just evaporate I don't see a clean way to export data, although I also can't imagine it'd be difficult to just copy/paste things to another platform. That said, since it's static-generated, as long as you keep the server itself up to date and don't mind the site looking dated over time... it'll be fine. The desktop app should still work, there's little security risk given the nature of what it is, the only problem would be if you use something like AWS and the lack of updates means you can't sync anymore because of some API token changes. Stick with SFTP and be happy with outdated themes in a few years and you're golden.

While it'll be super easy to move my site to another host if I ever choose to, I'm a little more concerned with how Publii handles it's "local copy" of things. I haven't tried it yet but it looks like, in Ubuntu Desktop anyway, it just creates a Publii folder in your $home/Documents folder, so I'm guessing I can just copy that to a new PC or reinstall of my OS? It's a small enough concern I haven't really looked into the specifics of that, but it's related to the Dropbox problem. I'm probably gonna try to move it to my Nextcloud folder so I can work on my site on any system I have Nextcloud on.

Similarly, I can't quite put my finger on it, but I read that this problem was solved and I'm not sure it was. When you are working in Publii and hit save it does little generations each time, and big changes (like a theme swap) re-generate the whole site. Fair, makes sense. However, when you sync the site, it looks like it's re-uploading the entire thing sometimes? I saw this complaint somewhere, thought "oh yeah I think it is doing that, weird," and then that same place had an update saying it was fixed in a version of Publii older than what I have. Might be my imagination, or it's changing more than I think when I notice it and just has more to sync. If it is a problem really big sites, such as something with a lot of photos or over time tons of posts, it could be a problem.

To be frank, none of those concerns are remotely big enough for me to care about, though. Each has a low to non-existent impact on single-user blogs, and the benefits of Publii far outweigh my worry. If I needed multiple authors, and/or needed something that would definitely be around for ages to come, I'd use something else... like Wordpress, probably. Since it's just me, and I'm content to spend a couple weekends transitioning to something else if the worst happens, I don't care. Publii's pretty cool.

This article was updated on 20/10/17 15:18:42