Dropbox is an incredibly useful and popular service that enables you to sync files from a variety of desktop and mobile devices. A growing number of applications, such as text editors, are being developed that enable you to create files and edit existing ones directly to Dropbox.
Recently, Dropbox announced an increase in included storage to 1TB for all Pro plan members while maintaining the same 2GB limit for free accounts. This announcement meant that for $10, we could get plenty of synced storage for multiple large sites, as well as numerous testing sites for more streamlined platforms like Grav.
Its built-in syncing functionality means that you can change and create files on virtually any system and have them automatically update across your desktop PCs, laptops, and even mobile devices.
We do the majority of our development on private, local servers. Server solutions like MAMP, WAMP, and OS X's built-in Apache make it easy to set up a development server, or even host a low-traffic site from a spare PC or Mac.
By setting up a symlink that creates a symbolic link between a folder in your Dropbox and your server's document root, you can make it so you can quickly and easily edit Grav from anywhere in the world (on any device) and have these changes automatically update to your home server, without any advanced server management magic or IT know-how.
Set up Grav on Dropbox
If you are setting up Grav for the first time, and want to take advantage of Dropbox, you can do so in two ways. Each of these methods have the same initial steps.
- Download the Grav zip file from GetGrav.org. You can do the same thing with any of the skeletons on Grav, as well.
- Unzip the file in your Dropbox directory.
- Rename the resulting folder to anything you would like. (ex: mainsite)
If you would like, you can set the home directory of your server to this new directory you have set up. This will automatically pull any changes from Grav made through Dropbox and keep your site updated, automatically.
If you have an existing Grav site and you want to set it up this way, simply move the root Grav directory to Dropbox, and set up the symlink as detailed below.
Setting Up Your Symlink
However, if you (like us) prefer to keep your local server separate from Dropbox, you can still take advantage of the sync by way of a symlink.
A symlink (also called a symbolic link) essentially acts as a virtual shortcut between one folder and another. Every other part of its host directory remains the same, but any referenced to the linked folder or files are automatically forwarded to the connected folder.
OS X
Setting up symbolic links on OS X is pretty easy. You will need to bring up terminal. Once you have, just follow these steps.
- Open Terminal.
- Navigate to the directory you have set up on your server as the document root. This will typically be the root by which all of your other sites are based. (example:
mycomputer\sites
) - Enter
ln -s ~/Dropbox/(your Grav directory)
(example:~/Dropbox/mainsite
) - Test your symbolic link by going to your browser and navigating to your site. (example:
http://localhost/mainsite
orhttp://yoursite.com/mainsite
)
At this point, you should be able to make a change to your site files using a Dropbox synced device and see these changes appear on refresh.
Windows
Windows supports symbolic linking, though it uses a slightly different method to accomplish the same task. The command is structured in this way: mklink <arguments> <symlink> <targetoflink>
.
For the most part, you will want to use the /j
argument which lets Windows know that you want to link a directory, rather than an individual file. If you want to only link an individual file, you would use /h
as the argument.
The <symlink>
argument is the name of your symbolic link. Basically, this becomes the name of the file that sits in the linked directory that forwards queries to the other folder. You can name this pretty much anything you want, but you should avoid naming it after an existing file or folder as this can cause confusion and possibly break functionality later on.
Other than this, the steps are pretty much the same as with OS X.
- Open Command Prompt by pressing the Windows key, typing
cmd
and hitting Enter. - Navigate to the directory you have set up on your server as the document root. This will typically be the root by which all of your other sites are based. (example:
mycomputer\sites
) - Enter
mklink /j "Grav Site" (Your Document Root Server Directory) (Your Dropbox Site Directory)
(example:mklink /j "Grav Site" c:\sites\ c:\dropbox\mainsite
) - Test your symbolic link by going to your browser and navigating to your site. (example:
http://localhost/mainsite
orhttp://yoursite.com/mainsite
)
Edit on Mobile Device
Here's the fun part. Your symbolic links are created and all you need to do is modify your site files to make changes and start editing your site from anywhere in the world.
Yes, this includes poolside while sipping on a colorful drink with a little umbrella in it.
On iOS, there are a number of great apps out there that sync directly to Dropbox, enabling you to edit text files on the fly, and even create new files and directories when you want to add content to your site.
You can choose to either set the root folder to the /user/
or /user/pages/
directory within your Grav install in these apps. By using the /user/
directory, you gain the ability to edit config files and other features of the site. The Pages subdirectory is where written content lives, giving you the ability to quickly browse and access just the content on the fly.
Here are some apps that work great with Dropbox for iOS:
There are also many great options for Android. Here are a couple:
So whether you're working from home on the same system you host your local development server from, or sipping drinks beachside from a tropical resort located in parts unknown, you can ensure your Grav site will be easy to update as long as you have access to Dropbox.