4.16 Publishing the site

G-Cows' users usually develop web sites on a local machine and upload their work on a remote web server. There are several ways to upload files on a remote web server; command lines tools or fancy graphical user interfaces can be used too send files via ftp or ssh.

I use rsync over a secure connection on my servers; but if you subscribe a cheap hosting account you'll probably need an ftp client; let's consider this situation since it's the most common.

We have to upload files within directory www/ on a remote server via ftp. We can choose one of the many ftp clients, but I prefer a program called Sitecopy (http://www.lyra.org/sitecopy/), which is already available in nearly all major Linux distributions and in FreeBSD ports collection.

Sitecopy allows to keep a local directory tree and a remote copy synchronized. Once it's properly setup, to upload all and only files which have been changed since the last update you only need to type:

sitecopy --update SITE

where SITE is a label assigned to your site.

Moreover, you can tune the update process until it completely fulfills your needs. As an example I keep xcf files (Gimp's native format) inside the images directory so I can easily find them, but I don't want to update them, so I tell Sitecopy to skip files *.xcf.

I won't explain how to configure Sitecopy since it is very well documented. Let's say that we've properly set up and that the command

sitecopy --update tutorial

will update the remote copy of our site.

Cows-mkgen creates a Makefile which should suffice most of your needs, but you may need some custom rules. If Cows-mkgen finds a file called Makefile.add in your site's root directory, it copy its content inside the generated Makefile.

File: Makefile.add:

__upload:
        sitecopy --update tutorial

publish: all __upload

The first additional rule synchronize the remote copy of the site with the local one. The second rule first update all local files and then upload changes.

Now, you simply need to type:

make publish

to update your site and publish modified files.

I usually work on my source files, using make to update the local copy of the site. When I'm satisfied with my changes, I type make publish to upload changes to the web server. If I forget to update the local copy make publish does it for me, since the target all is invoked before the __upload one. In other words it:

  1. updates local HTML files from local cows files;

  2. updates remote HTML files from local HTML files.

However, if for some reason I want to synchronize remote site with my local HTML files without updating them, I can simply type make __upload.

This manual can be downloaded from http://www.g-cows.org/.