After around a year of using WordPress for the majority of the websites I built for Ghost, I was looking for something different.
That isn’t to say that WordPress is bad – it isn’t – it’s just that for some of the projects I was working on, using WordPress was a bit like cracking a walnut with a sledgehammer.
Add to this the fact that the majority of our clients were having trouble understanding the WordPress administration interface (meaning that, more often than not, I ended up populating the content for them), I was looking for something better suited to the type of project I was working on.
CouchCMS is a lightweight content management system that is designed to work with pretty much any HTML template you wish to throw at it.
Unlike a lot of other CMSs I’ve used, which require that you convert your template into a theme (which, depending on the CMS at hand, can be hard work, not to meantion downright confusing for a beginner), Couch instead gets you to define the editable regions of your template via the addition of some special tags added to your existing markup, which it then uses to build the administration area of the site to your requirements.
But this post isn’t designed as a review of Couch (although if it was, it would probably say something like “two thumbs up”), or even a tutorial on how to use it - rather, the purpose of this post is to explain my plan to use Couch with Git.
Separation of data and logic
Since getting into Git I’ve discovered lots of really useful ways to make my life easier. For example, after following an article on how to Install and manage WordPress with Git, all the WordPress sites that I maintain on a daily basis are version controlled with the minimum of fuss, making it easy for me to update them as and when I need to.
This is achieved via the use of a submodule containing the core WordPress files (and nothing site specific), while the rest of the repository contained the bits specific to the site being built. This is very similar to the concept of the separation of data and logic.
I wanted the same with Couch, but the default install has at least two folders (
snippets) and one file (
config.php) that exist within the main couch folder.
I made a post in the forum about this, and found that the aforementioned folders are easily moved, but without a
config.php file in the correct place, Couch would just refuse to work. Although it looks as though the guy who wrote Couch might implement a fix for this himself at some point in the future, I’m impatient, so I made my own solution.
What I did
The solution, when you think about it, is really simple. First I made a copy of the default
config.example.php file, renamed it
config.php, then moved it into the root directory folder before customising its settings (while not forgetting to set the values for the
snippets folders), then created a new
config.php file in the
couch folder with the following content:
<?php $folder = dirname(dirname(__FILE__)); require $folder.'/config.php';
As you can see, this gets the path to the root folder (because relative paths don’t work), then uses it to require the
config.php file that has all your settings in it.
Now that the couch folder is standalone, you’re free to do whatever you want with it, such as set it up as a submodule, or simply ignore it from your Git repository.
I’ve tested this with Couch 1.2.5 and 1.3-RC1, and so far as I can see, it works fine with both (although I can’t see any reason why it shouldn’t work with any version of Couch, past or future).