Vous pouvez naviguer parmi les posts en glissant votre doigt.
Jekyll is a pretty powerful framework to quickly build nice & functional static websites. I use it to develop websites that don’t need any database and that can be deployed on only one machine.
How will this work: we work with Jekyll on our computer, and when we’re happy with a version, we deploy it so that the internet users car admire the final result. So, we will, in that order:
What we can get:
Jekyll (and know how to make sites with it!) and
rsync on your computer,
rsync installed on the distant machine.
rsync is by default installed on some Linux distributions; to check, you just have to type
rsync --version and if you don’t have the
rsync version, well… just
sudo apt-get install rsync!
Of course, what I will describe also works with
apache, but, well… I prefer
nginx. I’ll explain why some day in a post. It would be because of its speed and user-friendliness, I would say.
I strongly suggest to buy a domain name. I don’t have any preference for that (I know amen offers ones at very good prices), I prefer to vary the companies where I buy domain names. Let’s say that for this tutorial your domain name is hailcaesar.com (you can be a fan, and I like to see websites honoring my glory spreading all over the web).
Let’s start by creating our Jekyll website on our computer:
You can then do whatever you want with the website. Don’t forget to
jekyll build to have everything you need in the
_site folder or in any custom folder you configured to be the deliverable folder.
Now you have to configure the server. On it, you need to create the folder containing the website. Personally, because I like to be original, I usually put it in
/var/www/. And don’t forget to change the rights on the folder:
Always on the server, you have to configure nginx so that it redirects the user correctly. To make it simple, we’ll copy a default configuration and edit it:
In this file, here is what you’ll write:
To activate the virtual host of your website, you have to create a symbolic link:
Now retart nginx to make the changes taken into account:
Nginx is now ready and you can test the URL http://hailcaesar.com, you’ll be ont your Jekyll website.
With only one command, we’ll synchronize all the
_site folder (
-r) or any custom folder configured in
_config.yml with the distant folder, and we’ll delete obsolete files (
--del) and force the overwriting by more recent files (
--force). I also want to know what happens during the deployment (
-v) and check the progress (
To do this, I created a script,
deploy_jekyll.sh, that I execute everytime I’m happy. With the website development, I mean, because I’m often happy for any reason without wanting to deploy anything.
The script will check in your configuration if you chose another destination folder than
Here is what the beast looks like. Put it directly in your Jekyll folder (
site_hailcaesar here). You can fetch the version I update regularly on Github. It contains more options:
Don’t forget the traditionnal
sudo chmod 777 deploy_jekyll.sh if you want to execute this script. I put 777 because I usually commit it with with git and I want the other developers to be able to use and edit it. I’m sharing. Only with my code, I prefer to be clear about that, my wife being beautiful I don’t want you to be mistaken.
I put colors in the script so that it’s more readable, green meaning it’s a success and red… well the opposite! The website is emphasized in blue. The error list is displayed if required, and there are parameters (URL and destination folder).
Watch out when executing the script for the first time, you can get this message:
Even if you’ve already connected to the distant machine with its IP address, you’re now doing it with a particular host name, so it asks you if you want to go on. Just write
yes and you’ll get the message:
Last thing to do: in the
build, Jekyll should ignore
rsync_errors. To do so, you have to edit
_config.yml and put this line:
exclude: [deploy_jekyll.sh, rsync-errors].
And there you go!
Pretty simple, no? No heavy machinery, no thousands of things to install and configue. You can develop and commit if you want to, but you master the deployment. A simple
./deploy_jekyll in Jekyll working directory and you’re set!