installing.md (22300B)
1 --- 2 title: Install Hugo 3 linktitle: Install Hugo 4 description: Install Hugo on macOS, Windows, Linux, OpenBSD, 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 * OpenBSD 35 * FreeBSD 36 37 Hugo may also be compiled from source wherever the Go toolchain can run; e.g., on other operating systems such as DragonFly BSD, OpenBSD, Plan 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. 38 39 ## Quick Install 40 41 ### Binary (Cross-platform) 42 43 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. 44 45 Ideally, you should install it somewhere in your `PATH` for easy use. `/usr/local/bin` is the most probable location. 46 47 ### Docker 48 49 We currently do not offer official Hugo images for Docker, but we do recommend these up to date distributions: https://hub.docker.com/r/klakegg/hugo/ 50 51 ### Homebrew (macOS) 52 53 If you are on macOS and using [Homebrew][brew], you can install Hugo with the following one-liner: 54 55 {{< code file="install-with-homebrew.sh" >}} 56 brew install hugo 57 {{< /code >}} 58 59 For more detailed explanations, read the installation guides that follow for installing on macOS and Windows. 60 61 ### MacPorts (macOS) 62 63 If you are on macOS and using [MacPorts][macports], you can install Hugo with the following one-liner: 64 65 {{< code file="install-with-macports.sh" >}} 66 port install hugo 67 {{< /code >}} 68 69 ### Homebrew (Linux) 70 71 If you are using [Homebrew][linuxbrew] on Linux, you can install Hugo with the following one-liner: 72 73 {{< code file="install-with-linuxbrew.sh" >}} 74 brew install hugo 75 {{< /code >}} 76 77 Installation guides for Homebrew on Linux are available on their [website][linuxbrew]. 78 79 ### Chocolatey (Windows) 80 81 If you are on a Windows machine and use [Chocolatey][] for package management, you can install Hugo with the following one-liner: 82 83 {{< code file="install-with-chocolatey.ps1" >}} 84 choco install hugo -confirm 85 {{< /code >}} 86 87 Or if you need the “extended” Sass/SCSS version: 88 89 {{< code file="install-extended-with-chocolatey.ps1" >}} 90 choco install hugo-extended -confirm 91 {{< /code >}} 92 93 ### Scoop (Windows) 94 95 If you are on a Windows machine and use [Scoop][] for package management, you can install Hugo with the following one-liner: 96 97 ```bash 98 scoop install hugo 99 ``` 100 101 Or install the extended version with: 102 103 ```bash 104 scoop install hugo-extended 105 ``` 106 107 ### Source 108 109 #### Prerequisite Tools 110 111 * [Git][installgit] 112 * [Go (at least Go 1.11)](https://golang.org/dl/) 113 114 #### Fetch from GitHub 115 116 Since Hugo 0.48, Hugo uses the Go Modules support built into Go 1.11 to build. The easiest way to get started is to clone Hugo in a directory outside of the GOPATH, as in the following example: 117 118 {{< code file="from-gh.sh" >}} 119 mkdir $HOME/src 120 cd $HOME/src 121 git clone https://github.com/gohugoio/hugo.git 122 cd hugo 123 go install --tags extended 124 {{< /code >}} 125 126 Remove `--tags extended` if you do not want/need Sass/SCSS support. 127 128 {{% note %}} 129 If you are a Windows user, substitute the `$HOME` environment variable above with `%USERPROFILE%`. 130 {{% /note %}} 131 132 ## macOS 133 134 ### Assumptions 135 136 1. You know how to open the macOS terminal. 137 2. You're running a modern 64-bit Mac. 138 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.) 139 140 ### Pick Your Method 141 142 There are three ways to install Hugo on your Mac 143 144 1. A package manager, like [Homebrew][brew] (`brew`) or [MacPorts][macports] (`port`) 145 2. Distribution (i.e., tarball) 146 3. Building from Source 147 148 There is no "best" way to install Hugo on your Mac. You should use the method that works best for your use case. 149 150 #### Pros and Cons 151 152 There are pros and cons to each of the aforementioned methods: 153 154 1. **Package Manager.** Using a package manager 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 in Homebrew). Releases may lag a few days behind because it has to be coordinated with another team. Nevertheless, this is the recommended installation method if you want to work from a stable, widely used source. Package managers work well and they are easy to update. 155 156 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. 157 158 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. 159 160 {{% note %}} 161 Since building from source is appealing to more seasoned command line users, this guide will focus more on installing Hugo via Homebrew and Tarball. 162 {{% /note %}} 163 164 ### Install Hugo with Brew 165 166 {{< youtube WvhCGlLcrF8 >}} 167 168 #### Step 1: Install `brew` if you haven't already 169 170 Go to the `brew` website, <https://brew.sh/>, and follow the directions there. The most important step is the installation from the command line: 171 172 {{< code file="install-brew.sh" >}} 173 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 174 {{< /code >}} 175 176 #### Step 2: Run the `brew` Command to Install `hugo` 177 178 Installing Hugo using `brew` is as easy as the following: 179 180 {{< code file="install-brew.sh" >}} 181 brew install hugo 182 {{< /code >}} 183 184 If Homebrew is working properly, you should see something similar to the following: 185 186 ``` 187 ==> Downloading https://homebrew.bintray.com/bottles/hugo-0.21.sierra.bottle.tar.gz 188 ######################################################################### 100.0% 189 ==> Pouring hugo-0.21.sierra.bottle.tar.gz 190 🍺 /usr/local/Cellar/hugo/0.21: 32 files, 17.4MB 191 ``` 192 193 {{% note "Installing the Latest Hugo with Brew" %}} 194 Replace `brew install hugo` with `brew install hugo --HEAD` if you want the absolute latest in-development version. 195 {{% /note %}} 196 197 `brew` should have updated your path to include Hugo. You can confirm by opening a new terminal window and running a few commands: 198 199 ``` 200 $ # show the location of the hugo executable 201 which hugo 202 /usr/local/bin/hugo 203 204 # show the installed version 205 ls -l $( which hugo ) 206 lrwxr-xr-x 1 mdhender admin 30 Mar 28 22:19 /usr/local/bin/hugo -> ../Cellar/hugo/0.13_1/bin/hugo 207 208 # verify that hugo runs correctly 209 hugo version 210 Hugo Static Site Generator v0.13 BuildDate: 2015-03-09T21:34:47-05:00 211 ``` 212 213 ### Install Hugo from Tarball 214 215 #### Step 1: Decide on the location 216 217 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: 218 219 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. 220 221 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. 222 223 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. 224 225 All three locations will work for you. In the interest of brevity, this guide focuses on option #2. 226 227 #### Step 2: Download the Tarball 228 229 1. Open <https://github.com/gohugoio/hugo/releases> in your browser. 230 231 2. Find the current release by scrolling down and looking for the green tag that reads "Latest Release." 232 233 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. 234 235 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. 236 237 #### Step 3: Confirm your download 238 239 Verify that the tarball wasn't corrupted during the download: 240 241 ``` 242 tar tvf ~/Downloads/hugo_X.Y_osx-64bit.tgz 243 -rwxrwxrwx 0 0 0 0 Feb 22 04:02 hugo_X.Y_osx-64bit/hugo_X.Y_osx-64bit.tgz 244 -rwxrwxrwx 0 0 0 0 Feb 22 03:24 hugo_X.Y_osx-64bit/README.md 245 -rwxrwxrwx 0 0 0 0 Jan 30 18:48 hugo_X.Y_osx-64bit/LICENSE.md 246 ``` 247 248 The `.md` files are documentation for Hugo. The other file is the executable. 249 250 #### Step 4: Install Into Your `bin` Directory 251 252 ``` 253 # create the directory if needed 254 mkdir -p ~/bin 255 256 # make it the working directory 257 cd ~/bin 258 259 # extract the tarball 260 tar -xvzf ~/Downloads/hugo_X.Y_osx-64bit.tgz 261 Archive: hugo_X.Y_osx-64bit.tgz 262 x ./ 263 x ./hugo 264 x ./LICENSE.md 265 x ./README.md 266 267 # verify that it runs 268 ./hugo version 269 Hugo Static Site Generator v0.13 BuildDate: 2015-02-22T04:02:30-06:00 270 ``` 271 272 You may need to add your bin directory to your `PATH` environment 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. 273 274 ``` 275 # check if hugo is in the path 276 which hugo 277 /Users/USERNAME/bin/hugo 278 ``` 279 280 If `hugo` is not in your `PATH`: 281 282 1. Determine your default shell (zsh or bash). 283 284 ``` 285 echo $SHELL 286 ``` 287 288 2. Edit your profile. 289 290 If your default shell is zsh: 291 292 ``` 293 nano ~/.zprofile 294 ``` 295 296 If your default shell is bash: 297 298 ``` 299 nano ~/.bash_profile 300 ``` 301 302 3. Insert a line to add `$HOME/bin` to your existing `PATH`. 303 304 ``` 305 export PATH=$PATH:$HOME/bin 306 ``` 307 308 4. Save the file by pressing Control-X, then Y. 309 310 5. Close the terminal and open a new terminal to pick up the changes to your profile. Verify the change by running the `which hugo` command again. 311 312 You've successfully installed Hugo. 313 314 ### Build from Source on Mac 315 316 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: 317 318 ``` 319 brew install go 320 ``` 321 322 #### Step 1: Get the Source 323 324 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: 325 326 ``` 327 git clone https://github.com/gohugoio/hugo 328 ``` 329 330 {{% warning "Sometimes \"Latest\" = \"Bugs\""%}} 331 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). 332 {{% /warning %}} 333 334 #### Step 2: Compiling 335 336 Make the directory containing the source your working directory and then fetch Hugo's dependencies: 337 338 ``` 339 mkdir -p src/github.com/gohugoio 340 ln -sf $(pwd) src/github.com/gohugoio/hugo 341 342 go get 343 ``` 344 345 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. 346 347 Once you have properly configured your directory, you can compile Hugo using the following command: 348 349 ``` 350 go build -o hugo main.go 351 ``` 352 353 Then place the `hugo` executable somewhere in your `$PATH`. You're now ready to start using Hugo. 354 355 ## Windows 356 357 The following aims to be a complete guide to installing Hugo on your Windows PC. 358 359 {{< youtube G7umPCU-8xc >}} 360 361 ### Assumptions 362 363 1. You will use `C:\Hugo\Sites` as the starting point for your new project. 364 2. You will use `C:\Hugo\bin` to store executable files. 365 366 ### Set up Your Directories 367 368 You'll need a place to store the Hugo executable, your [content][], and the generated Hugo website: 369 370 1. Open Windows Explorer. 371 2. Create a new folder: `C:\Hugo`, assuming you want Hugo on your C drive, although this can go anywhere 372 3. Create a subfolder in the Hugo folder: `C:\Hugo\bin` 373 4. Create another subfolder in Hugo: `C:\Hugo\Sites` 374 375 ### Technical Users 376 377 1. Download the latest zipped Hugo executable from [Hugo Releases][releases]. 378 2. Extract all contents to your `..\Hugo\bin` folder. 379 3. 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. 380 381 ### Less-technical Users 382 383 1. Go to the [Hugo Releases][releases] page. 384 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. 385 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).) 386 4. Move the ZIP file into your `C:\Hugo\bin` folder. 387 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. 388 6. You should now have three new files: The hugo executable (`hugo.exe`), `LICENSE`, and `README.md`. 389 390 Now you need to add Hugo to your Windows PATH settings: 391 392 #### For Windows 10 Users: 393 394 * Right click on the **Start** button. 395 * Click on **System**. 396 * Click on **Advanced System Settings** on the right. 397 * Click on the **Environment Variables...** button on the bottom. 398 * In the User variables section, select the row labeled "Path" and click the **Edit...** button. 399 * Click the **Browse...** button and select the directory to which `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 itself.* 400 * Click OK at every window to exit. 401 402 #### For Windows 7 and 8.x users: 403 404 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]. 405 406 ### Verify the Executable 407 408 Run a few commands to verify that the executable is ready to run, and then build a sample site to get started. 409 410 #### 1. Open a Command Prompt 411 412 At the prompt, type `hugo help` and press the <kbd>Enter</kbd> key. You should see output that starts with: 413 414 ``` 415 hugo is the main command, used to build your Hugo site. 416 417 Hugo is a Fast and Flexible Static Site Generator 418 built with love by spf13 and friends in Go. 419 420 Complete documentation is available at https://gohugo.io/. 421 ``` 422 423 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. 424 425 At the prompt, change your directory to the `Sites` directory. 426 427 ``` 428 C:\Program Files> cd C:\Hugo\Sites 429 C:\Hugo\Sites> 430 ``` 431 432 #### 2. Run the Command 433 434 Run the command to generate a new site. I'm using `example.com` as the name of the site. 435 436 ``` 437 C:\Hugo\Sites> hugo new site example.com 438 ``` 439 440 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: 441 442 ``` 443 C:\Hugo\Sites> cd example.com 444 C:\Hugo\Sites\example.com> dir 445 Directory of C:\hugo\sites\example.com 446 447 04/13/2015 10:44 PM <DIR> . 448 04/13/2015 10:44 PM <DIR> .. 449 04/13/2015 10:44 PM <DIR> archetypes 450 04/13/2015 10:44 PM 83 config.toml 451 04/13/2015 10:44 PM <DIR> content 452 04/13/2015 10:44 PM <DIR> data 453 04/13/2015 10:44 PM <DIR> layouts 454 04/13/2015 10:44 PM <DIR> static 455 1 File(s) 83 bytes 456 7 Dir(s) 6,273,331,200 bytes free 457 ``` 458 459 ### Troubleshoot Windows Installation 460 461 [@dhersam][] has created a nice video on common issues: 462 463 {{< youtube c8fJIRNChmU >}} 464 465 ## Linux 466 467 ### Snap Package 468 469 In any of the [Linux distributions that support snaps][snaps], you may install the "extended" Sass/SCSS version with this command: 470 471 snap install hugo --channel=extended 472 473 To install the non-extended version without Sass/SCSS support: 474 475 snap install hugo 476 477 To switch between the two, use either `snap refresh hugo --channel=extended` or `snap refresh hugo --channel=stable`. 478 479 {{% note %}} 480 Hugo installed via 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). 481 {{% /note %}} 482 483 ### Debian and Ubuntu 484 485 [@anthonyfok](https://github.com/anthonyfok) and friends in the [Debian Go Packaging Team](https://go-team.pages.debian.net/) maintains an official hugo [Debian package](https://packages.debian.org/hugo) which is shared with [Ubuntu](https://packages.ubuntu.com/hugo) and is installable via `apt-get`: 486 487 sudo apt-get install hugo 488 489 What this installs depends on your Debian/Ubuntu version. On Ubuntu bionic (18.04), this installs the non-extended version without Sass/SCSS support. On Ubuntu disco (19.04), this installs the extended version with Sass/SCSS support. 490 491 This option is not recommended because the Hugo in Linux package managers for Debian and Ubuntu is usually a few versions behind as described [here](https://github.com/gcushen/hugo-academic/issues/703) 492 493 ### Arch Linux 494 495 You can also install Hugo from the Arch Linux [community](https://www.archlinux.org/packages/community/x86_64/hugo/) repository. Applies also to derivatives such as Manjaro. 496 497 ``` 498 sudo pacman -Syu hugo 499 ``` 500 501 ### Fedora, Red Hat and CentOS 502 503 Fedora maintains an [official package for Hugo](https://packages.fedoraproject.org/pkgs/hugo/hugo) which may be installed with: 504 505 sudo dnf install hugo 506 507 For the latest version, the Hugo package maintained by [@daftaupe](https://github.com/daftaupe) at Fedora Copr is recommended: 508 509 * <https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/> 510 511 See the [related discussion in the Hugo forums][redhatforum]. 512 513 ### openSUSE Tumbleweed 514 515 openSUSE maintains an [official package](https://software.opensuse.org/package/hugo) for the Tumbleweed rolling release distribution, it may be installed with: 516 517 ```` 518 sudo zypper install hugo 519 ```` 520 521 ### Solus 522 523 Solus includes Hugo in its package repository, it may be installed with: 524 525 ``` 526 sudo eopkg install hugo 527 ``` 528 529 ## OpenBSD 530 531 OpenBSD provides a package for Hugo via `pkg_add`: 532 533 doas pkg_add hugo 534 535 536 ## Upgrade Hugo 537 538 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. 539 540 ## Next Steps 541 542 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]. 543 544 [brew]: https://brew.sh/ 545 [macports]: https://www.macports.org/ 546 [Chocolatey]: https://chocolatey.org/ 547 [content]: /content-management/ 548 [@dhersam]: https://github.com/dhersam 549 [forum]: https://discourse.gohugo.io 550 [mage]: https://github.com/magefile/mage 551 [dep]: https://github.com/golang/dep 552 [highlight shortcode]: /content-management/shortcodes/#highlight 553 [installgit]: https://git-scm.com/ 554 [installgo]: https://golang.org/dl/ 555 [linuxbrew]: https://docs.brew.sh/Homebrew-on-Linux 556 [quickstart]: /getting-started/quick-start/ 557 [redhatforum]: https://discourse.gohugo.io/t/solved-fedora-copr-repository-out-of-service/2491 558 [releases]: https://github.com/gohugoio/hugo/releases 559 [Scoop]: https://scoop.sh/ 560 [snaps]: https://snapcraft.io/docs/installing-snapd 561 [windowsarch]: https://esupport.trendmicro.com/en-us/home/pages/technical-support/1038680.aspx 562 [Windows Environment Variables Editor]: https://eveditor.com/