Migrating joelforjava.com from WordPress to JBake

September 15, 2019

When I started this site back in 2016, I went with WordPress because it was the quickest solution I could find to get things off the ground. However, as time has progressed, it has become clear that it's a bit overkill for my needs. I don't plan on ever having users sign up for accounts, for example. It's just me and the stuff I write. Could that change? Possibly, but not likely. Meanwhile, static site generators, such as Gatsby, Sphinx, Jekyll, VuePress, and a trove of others have been gaining in popularity. That's when it hit me--all I really need is a basic static-type site.

While I really wanted to go with something like VuePress or Gatsby so that I could sharpen my now archaic JavaScript skills, I decided to go with JBake. JBake has features that were more familiar to me, including Freemarker and Groovy based templates and even has a Gradle plugin so that I could create a build script to help maintain the new version of the blog. Other offerings have similar features, but I've really missed working with Groovy and Gradle. These days, for better or worse, I'm mostly working with Python.

Since I didn't really have that many articles written over the years, it wasn't that much effort to copy everything over into new Markdown files, which is what I plan on using for most of my articles. I could've probably written something to copy the data from WordPress, but I copied them manually since it might've taken me longer to write a script.

So, here I am now. Everything copied over and I even have some new articles coming down the pipeline. Hopefully by the time you see this, I'll already have a new and improved layout.

To help me keep tabs on the site, I've added a couple of Gradle tasks, including one to check for articles still in draft and another that validates all of the links to make sure we don't have any that are broken. They're a bit messy, but I'm hoping to improve them over time. I'm also hoping to add a spellchecker task to help keep misspellings to a minimum. You can check out everything here.

I used the jbake command to initialize my site using jbake -i, which generated the default Freemarker templates. You can change the templating engine used by running jbake -i -t <ENGINE>, where ENGINE is one of freemarker, groovy, groovy-mte, thymeleaf, or jade. If you've already set up a Gradle build script, you can update the template property of the jbake as follows:

jbake {
    template = 'ENGINE'

Here, ENGINE is the same as for the jbake command. When initializing via Gradle, you'd run gradle bakeInit. Also, if you initialize a JBake site with Gradle and don't supply a template engine name, it will default to groovy instead of freemarker. When using Gradle, you can run the bake task to re-build your site and the bakePreview task to run in preview mode, similar to how jbake -s works. However, you'll need to run gradle bake each time you wish to update the deployed site. More information on the plugin and itse setup can be found on its GitHub page.

Building the site is only half the fun. If you want to host the site on something like GitHub Pages, you'll need to follow the steps there to set everything up. Once ready, you'd take the output from build/jbake and copy it to the root of your GitHub Pages repo. Regardless of what host you choose, you'll likely follow similar steps to upload your baked site for the world to see.

Thank you for reading and I hope to somehow keep articles coming even when I'm not able to work with Java as much. Strangely, it seems like the more I'm pushed away from the Java ecosystem, the more I want to work in it. I might post some Python and other language stuff here, too, but that kind of gets away from the whole 'Joel for Java' thing, doesn't it?