Différences entre versions de « Installer Hugo »

De Mi caja de notas

Ligne 3 : Ligne 3 :
 
Traduction en cours. [Seul le lien original fait référence](https://gohugo.io/tutorials/installing-on-mac/ "Permalien vers ")
 
Traduction en cours. [Seul le lien original fait référence](https://gohugo.io/tutorials/installing-on-mac/ "Permalien vers ")
  
Ce tutoriel vise à être un guide complet pour installer Hugo sur votre ordinateur Mac.
+
Ce tutoriel vise à être un guide complet pour installer [[Hugo]] sur votre ordinateur Mac.
  
 
== Hypothèses ==
 
== Hypothèses ==

Version du 8 mars 2017 à 17:32


Traduction en cours. [Seul le lien original fait référence](https://gohugo.io/tutorials/installing-on-mac/ "Permalien vers ")

Ce tutoriel vise à être un guide complet pour installer Hugo sur votre ordinateur Mac.

Hypothèses

1. Vous savez comment ouvrir une fenêtre de terminal. 1. Vous utilisez un Mac 64 bits moderne. 1. Vous utiliserez `~ / Sites` comme point de départ de votre site.

Choisissez votre méthode

Il existe trois façons d'installer Hugo sur votre ordinateur Mac : l'utilitaire `brew`, provenant de la distribution ou de la source. Il n'y a pas de "meilleur" moyen de le faire. Vous devez utiliser la méthode qui convient le mieux à votre cas d'utilisation.

Il y a des avantages et des inconvénients pour chacun.

1. `Brew` est le le moyen le plus simple et celui qui demande le moins de maintenance. Peu d’inconvénients. Le paquet par défaut sera pour la version la plus récente, par conséquent il n'aura pas de correctifs jusqu'à la prochaine version (sauf si vous l'installez avec l'option `--HEAD`). La sortie vers `brew` peut avoir quelques jours de délai parce qu'il doit être coordonné avec une autre équipe. Pourtant, je recommande `brew` si vous voulez travailler à partir d'une source stable, largement utilisé. Il fonctionne bien et reste vraiment facile à mettre à jour.

 2. Télécharger le tarball et l'installer à partir de celle-ci est également facile. Vous devez avoir quelques compétences de ligne de commande. Les mises à jour sont faciles, aussi. Vous répétez simplement le processus avec le nouveau binaire. Cela vous donne la flexibilité d'avoir plusieurs versions sur votre ordinateur. Si vous ne voulez pas utiliser `brew`, alors le binaire est un bon choix.

 3. Compiler à partir de la source représente le plus de travail. L'avantage est que vous n'avez pas à attendre une version pour ajouter des fonctionnalités ou des corrections de bugs. L'inconvénient est que vous avez besoin de passer plus de temps à gérer la configuration. Ce n'est pas énorme, mais c'est plus que les deux autres options.

Puisque c'est un guide how-to "débutant", je couvrirai les deux premières options en détail et aborderai plus rapidement la troisième.

Brew

Étape 1 : Installez `brew` si ce n’est déjà fait

Allez sur le site web de `brew`, [1](http://brew.sh/), et suivez les directions. Copiez et collez dans la fenêtre de votre terminal :

   /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


Le script explique ce qu’il va faire, puis m’a fait une pause avant de l’exécuter pour afficher un message « Installation successful! »


Étape 2 : Lancez la commande `brew` pour installer `hugo`

Premièrement, mettez à jour les formules et Homebrew lui-même en lançant la commande :

   $ brew update
   

Puis installez Hugo en lançant :

   $ brew install hugo
   ==> Downloading https://homebrew.bintray.com/bottles/hugo-0.19.sierra.bottle.tar
   ######################################################################## 100,0%
   ==> Pouring hugo-0.19.sierra.bottle.tar.gz
   ==> Caveats
   Bash completion has been installed to:
     /usr/local/etc/bash_completion.d
   ==> Summary
   🍺  /usr/local/Cellar/hugo/0.19: 32 files, 16.4MB
   

(Note : Remplacez `brew install hugo` par `brew install hugo --HEAD` si vous voulez la dernière version en développement, mais attention, il pourrait y avoir des bugs !)

`Brew` devrait avoir mis à jour votre chemin pour inclure Hugo. Confirmer en ouvrant une nouvelle fenêtre de terminal et en lançant quelques commandes :

   $ # montre l’endroit de l’executable hugo
   $ which hugo
   /usr/local/bin/hugo
   
   $ # présente la version installée
   $ ls -l $( which hugo )
   lrwxr-xr-x  1 xtof  admin  28  8 mar 09:14 /usr/local/bin/hugo -> ../Cellar/hugo/0.19/bin/hugo
   
   
   $ # vérifie que hugo fonctionne correctement
   $ hugo version
   Hugo Static Site Generator v0.19 darwin/amd64 BuildDate: 2017-02-27T11:21:29+01:00
   

Étape 3 : Vous avez terminé

Vous avez installé Hugo. Maintenant vous devez paramétrer votre site. Lisez le [Guide Quickstart en anglais](https://gohugo.io/overview/quickstart/), explorez le reste de la documentation, et si vous avez encore des questions, [demandez simplement !](http://discuss.gohugo.io/)

À partir de la Tarball

Étape 1 : Décidez de l’endroit

When installing from the tarball, you have to decide if you’re going to install the binary in `/usr/local/bin` or in your home directory. There are three camps on this:

 1. Install it in `/usr/local/bin` so that all the users on your system have access to it. This is a good idea because it’s a fairly standard place for executables. The downside is that you may need elevated privileges to put software into that location. Also, if there are multiple users on your system, they will all run the same version. Sometimes this can be an issue if you want to try out a new release.
 2. Install it in `~/bin` so that only you can execute it. This is a good idea because it’s easy to do, easy to maintain, and doesn’t require elevated privileges. The downside is that only you can run Hugo. If there are other users on your site, they have to maintain their own copies. That can lead to people running different versions. of course, this does make it easier for you to experiment with different releases.
 3. Install it in your `sites` directory. This is not a bad idea if you have only one site that you’re building. It keeps every thing in a single place. If you want to try out new releases, you can just make a copy of the entire site, update the Hugo executable, and have it.

All three locations will work for you. I’m going to document the second option, mostly because I’m comfortable with it.

Étape 2 : Téléchargez la Tarball

1. Open [2](https://github.com/spf13/hugo/releases) in your browser.

2. Find the current release by scrolling down and looking for the green tag that reads “Latest Release.”

3. Download the current tarball for the Mac. The name will be something like `hugo_X.Y_osx-64bit.tgz`, where `X.YY` is the release number.

4. By default, the tarball will be saved to your `~/Downloads`directory. If you chose to use a different location, you’ll need to change that in the following steps.

Étape 3 : Confirmez votre téléchargement

Verify that the tarball wasn’t corrupted during the download:

   $ tar tvf ~/Downloads/hugo_X.Y_osx-64bit.tgz
   -rwxrwxrwx  0 0      0           0 Feb 22 04:02 hugo_X.Y_osx-64bit/hugo_X.Y_osx-64bit.tgz
   -rwxrwxrwx  0 0      0           0 Feb 22 03:24 hugo_X.Y_osx-64bit/README.md
   -rwxrwxrwx  0 0      0           0 Jan 30 18:48 hugo_X.Y_osx-64bit/LICENSE.md
   

The `.md` files are documentation. The other file is the executable.

Étape 4 : Installez à l'intérieur de votre directory bin

   $ # create the directory if needed
   $ mkdir -p ~/bin
   
   $ # make it the working directory
   $ cd ~/bin
   
   $ # extract the tarball
   $ tar -xvzf ~/Downloads/hugo_X.Y_osx-64bit.tgz
   Archive:  hugo_X.Y_osx-64bit.tgz
     x ./
     x ./hugo
     x ./LICENSE.md
     x ./README.md
   
   $ # verify that it runs
   $ ./hugo version
   Hugo Static Site Generator v0.13 BuildDate: 2015-02-22T04:02:30-06:00
   

You may need to add your bin directory to your `PATH` variable. The `which` command will check for us. If it can find `hugo`, it will print the full path to it. Otherwise, it will not print anything.

   $ # check if hugo is in the path
   $ which hugo
   /Users/USERNAME/bin/hugo
   

If `hugo` is not in your `PATH`, add it by updating your `~/.bash_profile` file. First, start up an editor:

   $ nano ~/.bash_profile
   

Add a line to update your `PATH` variable:

   export PATH=$PATH:$HOME/bin
   

Then save the file by pressing Control-X, then Y to save the file and return to the prompt.

Close the terminal and then open a new terminal to pick up the changes to your profile. Verify by running the `which hugo`command again.

Étape 5 : Vous avez terminé

You’ve installed Hugo. Now you need to set up your site. Read the [Quickstart guide](https://gohugo.io/overview/quickstart/), explore the rest of the documentation, and if you still have questions [just ask!](http://discuss.gohugo.io/)

Construire à partir de la Source

If you want to compile Hugo yourself, you’ll need [Go](http://golang.org/), which is also available from Homebrew: `brew install go`.

Étape 1 : Obtenez la Source

If you want to compile a specific version, go to [3](https://github.com/spf13/hugo/releases) and download the source code for the version of your choice. If you want to compile Hugo with all the latest changes (which might include bugs), clone the Hugo repository:

   git clone https://github.com/spf13/hugo
   

Étape 2 : Compiler

Make the directory containing the source your working directory, then fetch Hugo’s dependencies:

   mkdir -p src/github.com/spf13
   ln -sf $(pwd) src/github.com/spf13/hugo
   
   # set the build path for Go
   export GOPATH=$(pwd)
   
   go get
   

This will fetch the absolute latest version of the dependencies, so if Hugo fails to build it may be because the author of a dependency introduced a breaking change.

Then compile:

   go build -o hugo main.go
   

Then place the `hugo` executable somewhere in your `$PATH`.

Étape 3 : Vous avez terminé

You probably know where to go from here.