Upping your WordPress game with Roots

5 August 2016 #Code

I’ve been designing and developing WordPress sites now for a few years. For all that time we’ve been building them in the same fashion.

Code a few static HTML/CSS layouts of the site

Install WordPress locally and run on MAMP

Use a blank theme as a foundation to build out the rest of the site

Deploy via FTP

Migrate the database with a plugin

Maintain the site as carefully as possible between local and live sites

That’s been fine enough while developing small websites on my own. But now creating more complex sites, a growing number of previous site builds to maintain and expanding to have more than one person looking at anyone project, things needed to change.

Not sure how I came across them but I found and have begun using Roots suite of WordPress tools. I’ll run through them in the order I started using them…

Sage is a WordPress starter theme. Its documentation explicitly states that is should not be your first. That’s good advice. There’s no way I could’ve figured all this out the first time around.

It takes the idea of a bare-bones blank theme and adds a lot of handy features like Sass and BrowserSync, neither of which I’d used before. But now couldn’t live without.

It helps to know how the command line works. I didn’t. Wes Bos’ Command Line Power User series got me up to speed real fast.

Although Roots offers two other tools to create even more complex WordPress installs, they’re not required. So I developed a few simple themes first to help learn how Sage worked, while keeping the rest of my development environment the same. You only need to learn so much at once.

Also I’m not a huge Bootstrap fan so while the theme uses it, you can easily strip it out for something more simple.

Now we’re getting serious. While MAMP can serve up a whole bunch of sites locally, it becomes an unmanaged mess quite quickly. There’s also zero guarantee that your local MAMP environment will be anything like the live environment you deploy to.

WordPress is quite bullet proof and will run on almost any server, but you can be left with a rude shock late in a project if you’re developing in hope.

Trellis is like installing a version of MAMP for each site you build, then deploying that exact environment to a live server. (I’m not entirely sure if that’s an accurate analogy but it makes sense in my head).

This means that the local server environment for the site you develop locally is the exact same server environment your site will be served on live. It’s also doing dozens of really smart things under the hood that I likely don’t don’t appreciate fully. But they include managing plugins via a text file using Composer, and automatically generating SSL certificates with Let’s Encrypt.

Learning how to get all this working has really done my head in on a number of occasions. But I’ve gone from never touching the command line to absolutely cramming my head full of CLI, Git, Gulp, NPM, Bower, etc in short time (I just did my first pull request this week!).

It’s a brave new world of development — to me — and it’s equal parts frustrating and exciting. Like learning anything new.

That’s not all

By going down this road I’ve switched from Coda to Sublime Text, learned my way around iTerm for the command line with Oh My Zsh, switched from shared hosting to cloud hosting on Vultr, gone from four to two-space indenting, upgraded to WP Migrate DB Pro. Almost everything I use from start to finish on a WordPress project is different now than it was a few months ago.

Also the things I’ve learned to get used to Roots tools have helped me wrap my head around other more modern projects like Jekyll.

Is it worth it?

So now after deploying multiple sites to cloud hosting, using Trellis with Bedrock and themes developed on Sage, I’m sold. I’m not always entirely certain why things work the way they do (the Roots forum can attest to this with my constant questions).

There’s just so much stuff going on under the hood that’s beyond my pay grade. While getting to know how all these tools worked it really did feel like bashing my head against a wall. Learning what felt at first like a more complicated way to do something I already knew.

The main benefits for me are the very structured method it forces you to take around developing and deploying websites. On my old sites keeping local and live versions in sync took a lot of diligence and good intentions.

Roots tools force you to develop local, test and deploy when ready. It makes a single text edit take a minute or two longer than it does to just go and edit a live site via FTP. But it also makes for more structured development that will save you headaches and double-guessing down the road.

Part of WordPress’ amazing appeal is the “five minute install”. That will still be appealing to me for small projects. But for as many projects as would benefit from using Roots I’ll use it. Taking a little extra time early in a project will save you plenty over its lifespan.