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://my-lab.fr/users/~me/
- 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 --gc --minify
rsync -avz --delete public/ username@webserver:public_html
The first command, hugo
, creates a public
folder containing the website. The options --gc --minify
are not required, but in production, it might be a good idea to clean up the cache and minify the content with these options. 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 --gc --minify
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 every time 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.
Forcing a secure HTTPS connection
Depending on the webserver configuration, your webpage might me accessible over HTTP and HTTPS. If you want to force the usage of a secure HTTPS connection, create the file static/.htaccess
with the following content:
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Using the CNRS webserver
Mathrice offers the hosting of a professional webpage to anyone belonging to a CNRS lab with the URL https://username.perso.math.cnrs.fr/
. To enable it, you need to connect to https://services.math.cnrs.fr/ and toggle the button “Internet Disk”. You might need to wait a few hours before the service is ready, but then it suffices to do:
hugo --gc --minify
rsync -avz --delete public/ username@disque.math.cnrs.fr:public