Manual Deployment

This page explains how to deploy your website manually. I still recommend you to learn git to store and save your source code (which is not stored on the webserver!) but this method is rather simple, especially if you do not change your website that much!

How ?

Assumptions:

  • Your webpage URL is https://website.com/~username/
  • On the webserver, your public folder is named ~/public_html

At the root of your website source code (on your computer), type the following commands in a terminal (the second line must obviously be modified accordingly):

hugo
rsync -avz --delete public/ username@webserver:~/public_html

The first command, hugo, creates a public folder containing the website. The second command, rsync, synchronizes the folders public and the remote one.

  • The scp command is not recommended because it does not remove deprecated files: if you decided to unpublish a document, it will not be erased and thus will still be published!
  • You can use a FTP software instead such as Filezilla

Scripting

These two commands can be obviously merged in a script, for example:

#!/usr/bin/env bash
# deploy.sh
hugo
rsync -avz --delete public/ username@webserver:~/public_html

That way, every time you want to upload your modification, you simply have to launch the script:

sh deploy.sh

SSH keys: login without password

You may have to type your password everytime you update your website. If that is the case, I highly recommend you to use SSH keys. It is quite simple to do yet very convenient.

Précédent
Suivant