Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Publishing a Site

laktek edited this page Sep 11, 2012 · 11 revisions

With punch publish (or punch p) command, you can publish a site to Amazon S3 or to a remote server using SFTP protocol.

You will need to specify the configurations for the preferred publishing strategy in config.json.

S3 Publishing Strategy

S3 publishing strategy can be used to serve static site using Amazon S3.

A sample configuration for S3 strategy would look like this:

	"publish" : {
		"strategy" : "s3", 
		"options" : {
			"bucket" : "bucketname",
			"key" : "key",
			"secret" : "secret"
		}
	}

Basically, you have to specify a S3 bucket to upload the site and credentials of a user (recommended to create a new user), who got privileges to write to the bucket.

Since Punch uses Knox to connect with S3, you can specify any other property supported by Knox in the options.

SFTP Publishing Strategy

SFTP publishing strategy can be used to publish your site to any server with SFTP access.

	"publish"       : {
		"strategy" : "sftp",
		"options" : {
			"host" : "hostname",
			"username" : "sftpuser",
			"port" : "22",
			"private_key" : "~/.ssh/id_rsa",
			"upload_path" : "/var/www/"
		}
	}

You must specify server's hostname and your username to login. Files will be uploaded to the remote path specified as upload_path.

Apart from the default options, you can specify any other options that are supported by node-sftp library.

Keep in Mind

  • Punch will generate the site before publishing. If you don't want to generate the site, set the generate option to false in publish configuration.

  • When a site is published, Punch will store the last published time in a hidden file named .last_published in the project's root directory. Next time, when you run punch publish it will only upload the files modified after the last published time. If you want to force upload the full site, just delete the .last_published file.

  • With current publishing strategies, removed files aren't deleted from the remote servers. You will need to delete them manually.

Defining a Custom Publishing Strategy

If you want to follow a different workflow or use some other mechanism to publish your site, you can define your own publishing strategy. Check the section on Defining a Custom Publishing Strategy to learn how to write one.