Maintenance mode for Statamic sites

We’ve done a few smaller projects with the relatively new flat-file CMS, Statamic. While it certainly has a few flaws and growing pains, it’s a promising system. I’m using it for this site.

One thing missing out of the box is the ability to put a site into “Offline mode”. ExpressionEngine, another CMS we have experience with, has this. It’s a nice little switch you can flip if you’re not wanting the public to see your site while in disarray during an update or something similar.

Here’s a relatively simple method we used recently to accomplish this. Basically, you’ll use a combination of environments (and environment variables) and redirects.

Set your dev and live environments your main settings.yaml file

    - 'http://localhost*'
    - 'http://example:2222*' // adjust to your local port
    - '*.dev'
    - '*'
    - '*'
    - '*'

In _config/environments/, add a file for each environment you setup in the previous step (if they don’t already exist)


Add a variable to each of these files, starting with dev.yaml

# Show the offline page template?
offline_mode: false

Same variable, different value for live.yaml

# Show the offline page template?
offline_mode: true

You now have a variable that can be used in your templates. So, let’s go ahead and use it in a simple redirect.

In your layout files (_themes/theme-name/layouts/default.html), add a redirect

{ { if offline_mode && segment_1 != "offline" } }
    { { redirect url="/offline" } }
{ { endif } }

Remove extra spaces between curly braces

Create an “offline” or maintenance mode template in your _content folder

Now you can deploy your site to the live server without worrying about things looking all busted. When you’re ready to flip the switch and make the site live, simply change the offline_mode variable to false in your live.yaml environment file.


Use this same redirect concept to see the live site during the build out using the logged_in global variable as the redirect if statement:

{ { if !logged_in && segment_1 != "offline" } }
    { { redirect url="/offline" } }
{ { endif } }

That will show guests the offline template while signed in users (content creators, clients, and developers) can see real content.

Notice anything all busted with this? Let me know.

Client Relationships

I gave a talk to design students at Rocky Mountain College of Art & Design a few months ago. The topic was “The Business of Design”. This is an excerpt from that talk and something I feel very strongly about.

Out of everything I’ll say, this is the most important.

Without good working relationships with your clients, your business will fail. With good client relationships, communication, and solid work ethic, you’ll be turning away projects.

Many clients with good budgets are nervous about working with independent designers because they’ve had less-than-awesome experiences working with others in the past. I can’t count the number of times I’ve heard a prospective client talk about how their previous designer didn’t follow through or bailed on them. It’s very rarely about the quality of the work; it’s about the relationship. And as with any relationship, it’s all about the communication.

If you’re going to miss a deadline, the client shouldn’t be hearing about it for the first time on that day. Communicate. If changes to a project scope require more time and money, the client shouldn’t find out about when they get the invoice. Communicate. A client that likes you is more likely to recommend you to other prospective clients. It’s simple. And a referral is the best and easiest way to grow your business.

These things don’t mean you should bend over backwards to every request or that you shouldn’t be professional. Setting clear expectations of what your role is as the designer and what they as the client are responsible for can do wonders in setting the stage for the working relationship. I very rarely reply to client emails in the evenings or on weekends. I don’t want to set the precedent that I’m available at all times. They respect my time because I’ve set standards. If some kind of emergency comes through and I’m able to, I’ll respond or make a quick change on something, but that is the exception, not the rule.