github.com/shohhei1126/hugo@v0.42.2-0.20180623210752-3d5928889ad7/docs/content/en/getting-started/installing.md (about)

     1  ---
     2  title: Install Hugo
     3  linktitle: Install Hugo
     4  description: Install Hugo on macOS, Windows, Linux, FreeBSD, and on any machine where the Go compiler tool chain can run.
     5  date: 2016-11-01
     6  publishdate: 2016-11-01
     7  lastmod: 2018-01-02
     8  categories: [getting started,fundamentals]
     9  authors: ["Michael Henderson"]
    10  keywords: [install,pc,windows,linux,macos,binary,tarball]
    11  menu:
    12    docs:
    13      parent: "getting-started"
    14      weight: 30
    15  weight: 30
    16  sections_weight: 30
    17  draft: false
    18  aliases: [/tutorials/installing-on-windows/,/tutorials/installing-on-mac/,/overview/installing/,/getting-started/install,/install/]
    19  toc: true
    20  ---
    21  
    22  
    23  {{% note %}}
    24  There is lots of talk about "Hugo being written in Go", but you don't need to install Go to enjoy Hugo. Just grab a precompiled binary!
    25  {{% /note %}}
    26  
    27  Hugo is written in [Go](https://golang.org/) with support for multiple platforms. The latest release can be found at [Hugo Releases][releases].
    28  
    29  Hugo currently provides pre-built binaries for the following:
    30  
    31  * macOS (Darwin) for x64, i386, and ARM architectures
    32  * Windows
    33  * Linux
    34  * FreeBSD
    35  
    36  Hugo may also be compiled from source wherever the Go compiler tool chain can run; e.g., on other operating systems such as DragonFly BSD, OpenBSD, Plan&nbsp;9, Solaris, and others. See <https://golang.org/doc/install/source> for the full set of supported combinations of target operating systems and compilation architectures.
    37  
    38  ## Quick Install
    39  
    40  ### Binary (Cross-platform)
    41  
    42  Download the appropriate version for your platform from [Hugo Releases][releases]. Once downloaded, the binary can be run from anywhere. You don't need to install it into a global location. This works well for shared hosts and other systems where you don't have a privileged account.
    43  
    44  Ideally, you should install it somewhere in your `PATH` for easy use. `/usr/local/bin` is the most probable location.
    45  
    46  ### Homebrew (macOS)
    47  
    48  If you are on macOS and using [Homebrew][brew], you can install Hugo with the following one-liner:
    49  
    50  {{< code file="install-with-homebrew.sh" >}}
    51  brew install hugo
    52  {{< /code >}}
    53  
    54  For more detailed explanations, read the installation guides that follow for installing on macOS and Windows.
    55  
    56  ### Chocolatey (Windows)
    57  
    58  If you are on a Windows machine and use [Chocolatey][] for package management, you can install Hugo with the following one-liner:
    59  
    60  {{< code file="install-with-chocolatey.ps1" >}}
    61  choco install hugo -confirm
    62  {{< /code >}}
    63  
    64  ### Source
    65  
    66  #### Prerequisite Tools
    67  
    68  * [Git][installgit]
    69  * [Go (latest or previous version)][installgo]
    70  
    71  #### Vendored Dependencies
    72  
    73  Hugo uses [dep][] to vendor dependencies, but we don't commit the vendored packages themselves to the Hugo git repository. Therefore, a simple `go get` is *not* supported because the command is not vendor aware.
    74  
    75  The simplest way is to use [mage][] (a Make alternative for Go projects.)
    76  
    77  #### Fetch from GitHub
    78  
    79  {{< code file="from-gh.sh" >}}
    80  go get github.com/magefile/mage
    81  go get -d github.com/gohugoio/hugo
    82  cd ${GOPATH:-$HOME/go}/src/github.com/gohugoio/hugo
    83  mage vendor
    84  mage install
    85  {{< /code >}}
    86  
    87  {{% note %}}
    88  If you are a Windows user, substitute the `$HOME` environment variable above with `%USERPROFILE%`.
    89  {{% /note %}}
    90  
    91  ## macOS
    92  
    93  ### Assumptions
    94  
    95  1. You know how to open the macOS terminal.
    96  2. You're running a modern 64-bit Mac.
    97  3. You will use `~/Sites` as the starting point for your site. (`~/Sites` is used for example purposes. If you are familiar enough with the command line and file system, you should have no issues following along with the instructions.)
    98  
    99  ### Pick Your Method
   100  
   101  There are three ways to install Hugo on your Mac
   102  
   103  1. The [Homebrew][brew] `brew` utility
   104  2. Distribution (i.e., tarball)
   105  3. Building from Source
   106  
   107  There is no "best" way to install Hugo on your Mac. You should use the method that works best for your use case.
   108  
   109  #### Pros and Cons
   110  
   111  There are pros and cons to each of the aforementioned methods:
   112  
   113  1. **Homebrew.** Homebrew is the simplest method and will require the least amount of work to maintain. The drawbacks aren't severe. The default package will be for the most recent release, so it will not have bug fixes until the next release (i.e., unless you install it with the `--HEAD` option). Hugo `brew` releases may lag a few days behind because it has to be coordinated with another team. Nevertheless, `brew` is the recommended installation method if you want to work from a stable, widely used source. Brew works well and is easy to update.
   114  
   115  2. **Tarball.** Downloading and installing from the tarball is also easy, although it requires a few more command line skills than does Homebrew. Updates are easy as well: you just repeat the process with the new binary. This gives you the flexibility to have multiple versions on your computer. If you don't want to use `brew`, then the tarball/binary is a good choice.
   116  
   117  3. **Building from Source.** Building from source is the most work. The advantage of building from source is that you don't have to wait for a release to add features or bug fixes. The disadvantage is that you need to spend more time managing the setup, which is manageable but requires more time than the preceding two options.
   118  
   119  {{% note %}}
   120  Since building from source is appealing to more seasoned command line users, this guide will focus more on installing Hugo via Homebrew and Tarball.
   121  {{% /note %}}
   122  
   123  ### Install Hugo with Brew
   124  
   125  {{< youtube WvhCGlLcrF8 >}}
   126  
   127  #### Step 1: Install `brew` if you haven't already
   128  
   129  Go to the `brew` website, <https://brew.sh/>, and follow the directions there. The most important step is the installation from the command line:
   130  
   131  {{< code file="install-brew.sh" >}}
   132  ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
   133  {{< /code >}}
   134  
   135  #### Step 2: Run the `brew` Command to Install `hugo`
   136  
   137  Installing Hugo using `brew` is as easy as the following:
   138  
   139  {{< code file="install-brew.sh" >}}
   140  brew install hugo
   141  {{< /code >}}
   142  
   143  If Homebrew is working properly, you should see something similar to the following:
   144  
   145  ```
   146  ==> Downloading https://homebrew.bintray.com/bottles/hugo-0.21.sierra.bottle.tar.gz
   147  ######################################################################### 100.0%
   148  ==> Pouring hugo-0.21.sierra.bottle.tar.gz
   149  🍺  /usr/local/Cellar/hugo/0.21: 32 files, 17.4MB
   150  ```
   151  
   152  {{% note "Installing the Latest Hugo with Brew" %}}
   153  Replace `brew install hugo` with `brew install hugo --HEAD` if you want the absolute latest in-development version.
   154  {{% /note %}}
   155  
   156  `brew` should have updated your path to include Hugo. You can confirm by opening a new terminal window and running a few commands:
   157  
   158  ```
   159  $ # show the location of the hugo executable
   160  which hugo
   161  /usr/local/bin/hugo
   162  
   163  # show the installed version
   164  ls -l $( which hugo )
   165  lrwxr-xr-x  1 mdhender admin  30 Mar 28 22:19 /usr/local/bin/hugo -> ../Cellar/hugo/0.13_1/bin/hugo
   166  
   167  # verify that hugo runs correctly
   168  hugo version
   169  Hugo Static Site Generator v0.13 BuildDate: 2015-03-09T21:34:47-05:00
   170  ```
   171  
   172  ### Install Hugo from Tarball
   173  
   174  #### Step 1: Decide on the location
   175  
   176  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:
   177  
   178  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.
   179  
   180  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.
   181  
   182  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 make a copy of the entire site and update the Hugo executable.
   183  
   184  All three locations will work for you. In the interest of brevity, this guide focuses on option #2.
   185  
   186  #### Step 2: Download the Tarball
   187  
   188  1. Open <https://github.com/gohugoio/hugo/releases> in your browser.
   189  
   190  2. Find the current release by scrolling down and looking for the green tag that reads "Latest Release."
   191  
   192  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.
   193  
   194  4. By default, the tarball will be saved to your `~/Downloads` directory. If you choose to use a different location, you'll need to change that in the following steps.
   195  
   196  #### Step 3: Confirm your download
   197  
   198  Verify that the tarball wasn't corrupted during the download:
   199  
   200  ```
   201  tar tvf ~/Downloads/hugo_X.Y_osx-64bit.tgz
   202  -rwxrwxrwx  0 0      0           0 Feb 22 04:02 hugo_X.Y_osx-64bit/hugo_X.Y_osx-64bit.tgz
   203  -rwxrwxrwx  0 0      0           0 Feb 22 03:24 hugo_X.Y_osx-64bit/README.md
   204  -rwxrwxrwx  0 0      0           0 Jan 30 18:48 hugo_X.Y_osx-64bit/LICENSE.md
   205  ```
   206  
   207  The `.md` files are documentation for Hugo. The other file is the executable.
   208  
   209  #### Step 4: Install Into Your `bin` Directory
   210  
   211  ```
   212  # create the directory if needed
   213  mkdir -p ~/bin
   214  
   215  # make it the working directory
   216  cd ~/bin
   217  
   218  # extract the tarball
   219  tar -xvzf ~/Downloads/hugo_X.Y_osx-64bit.tgz
   220  Archive:  hugo_X.Y_osx-64bit.tgz
   221    x ./
   222    x ./hugo
   223    x ./LICENSE.md
   224    x ./README.md
   225  
   226  # verify that it runs
   227  ./hugo version
   228  Hugo Static Site Generator v0.13 BuildDate: 2015-02-22T04:02:30-06:00
   229  ```
   230  
   231  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.
   232  
   233  ```
   234  # check if hugo is in the path
   235  which hugo
   236  /Users/USERNAME/bin/hugo
   237  ```
   238  
   239  If `hugo` is not in your `PATH`, add it by updating your `~/.bash_profile` file. First, start up an editor:
   240  
   241  ```
   242  nano ~/.bash_profile
   243  ```
   244  
   245  Add a line to update your `PATH` variable:
   246  
   247  ```
   248  export PATH=$PATH:$HOME/bin
   249  ```
   250  
   251  Then save the file by pressing Control-X, then Y to save the file and return to the prompt.
   252  
   253  Close the terminal and open a new terminal to pick up the changes to your profile. Verify your success by running the `which hugo` command again.
   254  
   255  You've successfully installed Hugo.
   256  
   257  ### Build from Source on Mac
   258  
   259  If you want to compile Hugo yourself, you'll need to install Go (aka Golang). You can [install Go directly from the Go website](https://golang.org/dl/) or via Homebrew using the following command:
   260  
   261  ```
   262  brew install go
   263  ```
   264  
   265  #### Step 1: Get the Source
   266  
   267  If you want to compile a specific version of Hugo, go to <https://github.com/gohugoio/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:
   268  
   269  ```
   270  git clone https://github.com/gohugoio/hugo
   271  ```
   272  
   273  {{% warning "Sometimes \"Latest\" = \"Bugs\""%}}
   274  Cloning the Hugo repository directly means taking the good with the bad. By using the bleeding-edge version of Hugo, you make your development susceptible to the latest features, as well as the latest bugs. Your feedback is appreciated. If you find a bug in the latest release, [please create an issue on GitHub](https://github.com/gohugoio/hugo/issues/new).
   275  {{% /warning %}}
   276  
   277  #### Step 2: Compiling
   278  
   279  Make the directory containing the source your working directory and then fetch Hugo's dependencies:
   280  
   281  ```
   282  mkdir -p src/github.com/gohugoio
   283  ln -sf $(pwd) src/github.com/gohugoio/hugo
   284  
   285  # set the build path for Go
   286  export GOPATH=$(pwd)
   287  
   288  go get
   289  ```
   290  
   291  This will fetch the absolute latest version of the dependencies. If Hugo fails to build, it may be the result of a dependency's author introducing a breaking change.
   292  
   293  Once you have properly configured your directory, you can compile Hugo using the following command:
   294  
   295  ```
   296  go build -o hugo main.go
   297  ```
   298  
   299  Then place the `hugo` executable somewhere in your `$PATH`. You're now ready to start using Hugo.
   300  
   301  ## Windows
   302  
   303  The following aims to be a complete guide to installing Hugo on your Windows PC.
   304  
   305  {{< youtube G7umPCU-8xc >}}
   306  
   307  ### Assumptions
   308  
   309  1. You will use `C:\Hugo\Sites` as the starting point for your new project.
   310  2. You will use `C:\Hugo\bin` to store executable files.
   311  
   312  ### Set up Your Directories
   313  
   314  You'll need a place to store the Hugo executable, your [content][], and the generated Hugo website:
   315  
   316  1. Open Windows Explorer.
   317  2. Create a new folder: `C:\Hugo`, assuming you want Hugo on your C drive, although this can go anywhere
   318  3. Create a subfolder in the Hugo folder: `C:\Hugo\bin`
   319  4. Create another subfolder in Hugo: `C:\Hugo\Sites`
   320  
   321  ### Technical Users
   322  
   323  1. Download the latest zipped Hugo executable from [Hugo Releases][releases].
   324  2. Extract all contents to your `..\Hugo\bin` folder.
   325  3. The `hugo` executable will be named as `hugo_hugo-version_platform_arch.exe`. Rename the executable to `hugo.exe` for ease of use.
   326  4. In PowerShell or your preferred CLI, add the `hugo.exe` executable to your PATH by navigating to `C:\Hugo\bin` (or the location of your hugo.exe file) and use the command `set PATH=%PATH%;C:\Hugo\bin`. If the `hugo` command does not work after a reboot, you may have to run the command prompt as administrator.
   327  
   328  ### Less-technical Users
   329  
   330  1. Go to the [Hugo Releases][releases] page.
   331  2. The latest release is announced on top. Scroll to the bottom of the release announcement to see the downloads. They're all ZIP files.
   332  3. Find the Windows files near the bottom (they're in alphabetical order, so Windows is last) – download either the 32-bit or 64-bit file depending on whether you have 32-bit or 64-bit Windows. (If you don't know, [see here](https://esupport.trendmicro.com/en-us/home/pages/technical-support/1038680.aspx).)
   333  4. Move the ZIP file into your `C:\Hugo\bin` folder.
   334  5. Double-click on the ZIP file and extract its contents. Be sure to extract the contents into the same `C:\Hugo\bin` folder – Windows will do this by default unless you tell it to extract somewhere else.
   335  6. You should now have three new files: hugo executable (e.g. `hugo_0.18_windows_amd64.exe`), `license.md`, and `readme.md`. (You can delete the ZIP download now.) Rename that hugo executable (`hugo_hugo-version_platform_arch.exe`) to `hugo.exe` for ease of use.
   336  
   337  Now you need to add Hugo to your Windows PATH settings:
   338  
   339  #### For Windows 10 Users:
   340  
   341  * Right click on the **Start** button.
   342  * Click on **System**.
   343  * Click on **Advanced System Settings** on the left.
   344  * Click on the **Environment Variables...** button on the bottom.
   345  * In the User variables section, find the row that starts with PATH (PATH will be all caps).
   346  * Double-click on **PATH**.
   347  * Click the **New...** button.
   348  * Type in the folder where `hugo.exe` was extracted, which is `C:\Hugo\bin` if you went by the instructions above. *The PATH entry should be the folder where Hugo lives and not the binary.* Press <kbd>Enter</kbd> when you're done typing.
   349  * Click OK at every window to exit.
   350  
   351  {{% note "Path Editor in Windows 10"%}}
   352  The path editor in Windows 10 was added in the large [November 2015 Update](https://blogs.windows.com/windowsexperience/2015/11/12/first-major-update-for-windows-10-available-today/). You'll need to have that or a later update installed for the above steps to work. You can see what Windows 10 build you have by clicking on the <i class="fa fa-windows"></i>&nbsp;Start button → Settings → System → About. See [here](https://www.howtogeek.com/236195/how-to-find-out-which-build-and-version-of-windows-10-you-have/) for more.)
   353  {{% /note %}}
   354  
   355  #### For Windows 7 and 8.x users:
   356  
   357  Windows 7 and 8.1 do not include the easy path editor included in Windows 10, so non-technical users on those platforms are advised to install a free third-party path editor like [Windows Environment Variables Editor][Windows Environment Variables Editor] or [Path Editor](https://patheditor2.codeplex.com/).
   358  
   359  ### Verify the Executable
   360  
   361  Run a few commands to verify that the executable is ready to run, and then build a sample site to get started.
   362  
   363  #### 1. Open a Command Prompt
   364  
   365  At the prompt, type `hugo help` and press the <kbd>Enter</kbd> key. You should see output that starts with:
   366  
   367  ```
   368  hugo is the main command, used to build your Hugo site.
   369  
   370  Hugo is a Fast and Flexible Static Site Generator
   371  built with love by spf13 and friends in Go.
   372  
   373  Complete documentation is available at https://gohugo.io/.
   374  ```
   375  
   376  If you do, then the installation is complete. If you don't, double-check the path that you placed the `hugo.exe` file in and that you typed that path correctly when you added it to your `PATH` variable. If you're still not getting the output, search the [Hugo discussion forum][forum] to see if others have already figured out our problem. If not, add a note---in the "Support" category---and be sure to include your command and the output.
   377  
   378  At the prompt, change your directory to the `Sites` directory.
   379  
   380  ```
   381  C:\Program Files> cd C:\Hugo\Sites
   382  C:\Hugo\Sites>
   383  ```
   384  
   385  #### 2. Run the Command
   386  
   387  Run the command to generate a new site. I'm using `example.com` as the name of the site.
   388  
   389  ```
   390  C:\Hugo\Sites> hugo new site example.com
   391  ```
   392  
   393  You should now have a directory at `C:\Hugo\Sites\example.com`. Change into that directory and list the contents. You should get output similar to the following:
   394  
   395  ```
   396  C:\Hugo\Sites> cd example.com
   397  C:\Hugo\Sites\example.com> dir
   398  Directory of C:\hugo\sites\example.com
   399  
   400  04/13/2015  10:44 PM    <DIR>          .
   401  04/13/2015  10:44 PM    <DIR>          ..
   402  04/13/2015  10:44 PM    <DIR>          archetypes
   403  04/13/2015  10:44 PM                83 config.toml
   404  04/13/2015  10:44 PM    <DIR>          content
   405  04/13/2015  10:44 PM    <DIR>          data
   406  04/13/2015  10:44 PM    <DIR>          layouts
   407  04/13/2015  10:44 PM    <DIR>          static
   408                 1 File(s)             83 bytes
   409                 7 Dir(s)   6,273,331,200 bytes free
   410  ```
   411  
   412  ### Troubleshoot Windows Installation
   413  
   414  [@dhersam][] has created a nice video on common issues:
   415  
   416  {{< youtube c8fJIRNChmU >}}
   417  
   418  ## Linux
   419  
   420  ### Snap Package
   421  
   422  In any of the [Linux distributions that support snaps][snaps]:
   423  
   424  ```
   425  snap install hugo
   426  ```
   427  
   428  ### Debian and Ubuntu
   429  
   430  Debian and Ubuntu provide a `hugo` version via `apt-get`:
   431  
   432  ```
   433  sudo apt-get install hugo
   434  ```
   435  
   436  #### Pros
   437  
   438  * Native Debian/Ubuntu package maintained by Debian Developers
   439  * Pre-installed bash completion script and `man` pages
   440  
   441  #### Cons
   442  
   443  * Might not be the latest version, especially if you are using an older, stable version (e.g., Ubuntu 16.04 LTS). Until backports and PPA are available, you may consider installing the Hugo snap package to get the latest version of Hugo.
   444  
   445  {{% note %}}
   446  Hugo-as-a-snap can write only inside the user’s `$HOME` directory---and gvfs-mounted directories owned by the user---because of Snaps’ confinement and security model. More information is also available [in this related GitHub issue](https://github.com/gohugoio/hugo/issues/3143). Use ```sudo snap install hugo --classic``` to disable the default security model if you want hugo to be able to have write access in other paths besides the user’s `$HOME` directory.
   447  {{% /note %}}
   448  
   449  ### Arch Linux
   450  
   451  You can also install Hugo from the Arch Linux [community](https://www.archlinux.org/packages/community/x86_64/hugo/) repository. Applies also for derivatives such as Manjaro.
   452  
   453  ```
   454  sudo pacman -Sy hugo
   455  ```
   456  
   457  ### Fedora
   458  
   459  Fedora provides a package for Hugo. The installation is done with the command :
   460  
   461  ```
   462  sudo dnf install hugo
   463  ```
   464  
   465  ### CentOS, and Red Hat
   466  
   467  * <https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/>
   468  
   469  See the [related discussion in the Hugo forums][redhatforum].
   470  
   471  ## Upgrade Hugo
   472  
   473  Upgrading Hugo is as easy as downloading and replacing the executable you’ve placed in your `PATH` or run `brew upgrade hugo` if using Homebrew.
   474  
   475  ## Install Pygments (Optional)
   476  
   477  The Hugo executable has one *optional* external dependency for source code highlighting ([Pygments][pygments]).
   478  
   479  If you want to have source code highlighting using the [highlight shortcode][], you need to install the Python-based Pygments program. The procedure is outlined on the [Pygments homepage][pygments].
   480  
   481  ## Next Steps
   482  
   483  Now that you've installed Hugo, read the [Quick Start guide][quickstart] and explore the rest of the documentation. If you have questions, ask the Hugo community directly by visiting the [Hugo Discussion Forum][forum].
   484  
   485  [brew]: https://brew.sh/
   486  [Chocolatey]: https://chocolatey.org/
   487  [content]: /content-management/
   488  [@dhersam]: https://github.com/dhersam
   489  [forum]: https://discourse.gohugo.io
   490  [mage]: https://github.com/magefile/mage
   491  [dep]: https://github.com/golang/dep
   492  [highlight shortcode]: /content-management/shortcodes/#highlight
   493  [installgit]: http://git-scm.com/
   494  [installgo]: https://golang.org/dl/
   495  [Path Editor]: https://patheditor2.codeplex.com/
   496  [pygments]: http://pygments.org
   497  [quickstart]: /getting-started/quick-start/
   498  [redhatforum]: https://discourse.gohugo.io/t/solved-fedora-copr-repository-out-of-service/2491
   499  [releases]: https://github.com/gohugoio/hugo/releases
   500  [snaps]: http://snapcraft.io/docs/core/install
   501  [windowsarch]: https://esupport.trendmicro.com/en-us/home/pages/technical-support/1038680.aspx
   502  [Windows Environment Variables Editor]: http://eveditor.com/