hugo/content/getting-started/installing.md
Bjørn Erik Pedersen 337d0c5f51 Squashed 'docs/' changes from 56c34962c..dce236ad1
dce236ad1 Wrap up the bundle etc. edits for now
27d058566 Add the bundle tree to the organization bundle
a83f750dd Move organization.md to its own bundle
01ec4f462 Make the image docs a bundle
60de1e090 Some more resources copy-edits
05d763c0c Some resource copy-edits
6299d6dbb Update the imgproc shortcode
59e0fc209 Add headless bundle documentation
a3bbf60bf Link Page Resources page from Front Matter page
830576f86 Update order significance section, add counter section
3b1836509 Revert the recent change made to default list template
886ed0e10 Page Bundles draft rev 2
f530d1a7a image processing and page resources made into regular .md
ec47cecda Finalised Page Resources and Image Processing Moved Page Resources and Impage Processing out of the Bundle section and at the root of the Content Management section
253092335 Modified front matter metadata exemple. Added yaml version.
da5e4f476 Adding date in the front-matter; missed in previous commit
6bc3ced13 Add rough draft for page and section bundles
a0e44458f Image processing first draft, Resources second read/fix
2367f0b78 data: Remove duplicate layouts in table
c2f179839 First draft of bundles/resources (covers resources and metadata)
2a3f9a613 Add weights to pages in Bundles branch
9a0146cc0 Switch front-matter format of Bundles doc to yaml; add front-matter
1295fc083 First draft for Bundles documentation organization structure
5a2e52231 Fix archetype paths
9c2e5c063 Merge commit '22cced34fc608256f8271ad591a5ccca991bb164'
22cced34f Squashed 'themes/gohugoioTheme/' changes from 75da2f6b..ecad8247
55d16c9a1 Fix broken sentence in multilingual sections
a76895ad2 Replace the outdated Emacs package with new one
e6cf1dec0 Remove obsolete link to hugo roadmap
dd2fd145b Add GitLab Pages to mentioned hosters (#309)
a05ce6bf6 Add 0.34 release notes poster
5c0ebdfca Release 0.34
13c2f3dc8 Merge branch 'temp34'
e6b5ffa04 Add 0.34 poster
1e1960496 releaser: Add release notes to /docs for release of 0.34
ac3efe182 releaser: Bump versions for release of 0.34
8f91f62d8 Fixes #222
cca35dbe4 Fix example
eaaa21ca1 Add missing params key
00d0b0363 Adding new Blogger utility to tools/migrations
7d36d579e Updated the line number for Dockerfile pointer
852188f85 Update installing.md with Fedora instructions
4d151a3ab Update search.md
4c2750bfb Update deployment-with-nanobox.md
c3cc9cd49 configuration: Remove defaultExtension from docs
f7c96b4b5 Update GitHub Pages documentation
55787f09a Merge branch 'rmetzler-menu-link-title'
2abbd9bd9 Merge branch 'master' into menu-link-title
e1fd710b7 Bring archetypes in from theme.
daf6f51c0 Mention the significance of leading 0 in int fn string input
07f498755 Add documentation for `cond` function.
050ccd12b Add documentation for the .HasShortcode function
919af9071 Correct anchor under 'Add custom metadata to a Taxonomy Term'
55600b4ff More layouts work
201cf4f67 Add some more single page layout variants
d5e7c03e2 Rework the layouts doc
84622e67c Cleans up the code sample
c231c9bd5 Add a new note to 0.33 relnotes
328ec9930 Release 0.33
b108fcc7b Merge branch 'temp33' into next
ab9d9ee65 releaser: Prepare repository for 0.34-DEV
e20c75320 releaser: Add release notes to /docs for release of 0.33
49f24dcd1 releaser: Bump versions for release of 0.33
9c8e5e207 Update 0.33 poster
7655603c8 Regenerate the docshelper data
16dc99583 Add Hugo 0.33 poster
ce40cc197 Merge commit '3cf4300097610bb8b5bd0686d96d1df5db641895'
9a3085523 releaser: Prepare repository for 0.33-DEV
a52db97d8 fixing typos and syntax for consistency
64525670f ádd title to some menu entries. This needs hugo >= v0.32
85d415ab2 ádd examples for menu .Title and .Page

git-subtree-dir: docs
git-subtree-split: dce236ad1258a9d9a0ee209f02b2e1f65b46f0fb
2018-01-31 11:07:47 +01:00

21 KiB
Raw Blame History

title linktitle description date publishdate lastmod categories authors keywords menu weight sections_weight draft aliases toc
Install Hugo Install Hugo Install Hugo on macOS, Windows, Linux, FreeBSD, and on any machine where the Go compiler tool chain can run. 2016-11-01 2016-11-01 2018-01-02
getting started
fundamentals
Michael Henderson
install
pc
windows
linux
macos
binary
tarball
docs
parent weight
getting-started 30
30 30 false
/tutorials/installing-on-windows/
/tutorials/installing-on-mac/
/overview/installing/
/getting-started/install
/install/
true

{{% note %}} 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! {{% /note %}}

Hugo is written in Go with support for multiple platforms. The latest release can be found at Hugo Releases.

Hugo currently provides pre-built binaries for the following:

  • macOS (Darwin) for x64, i386, and ARM architectures
  • Windows
  • Linux
  • FreeBSD

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 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.

Quick Install

Binary (Cross-platform)

Download the appropriate version for your platform from Hugo 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.

Ideally, you should install it somewhere in your PATH for easy use. /usr/local/bin is the most probable location.

Homebrew (macOS)

If you are on macOS and using Homebrew, you can install Hugo with the following one-liner:

{{< code file="install-with-homebrew.sh" >}} brew install hugo {{< /code >}}

For more detailed explanations, read the installation guides that follow for installing on macOS and Windows.

Chocolatey (Windows)

If you are on a Windows machine and use Chocolatey for package management, you can install Hugo with the following one-liner:

{{< code file="install-with-chocolatey.ps1" >}} choco install hugo -confirm {{< /code >}}

Source

Prerequisite Tools

Vendored Dependencies

Hugo uses govendor 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. You must use govendor to fetch Hugo's dependencies.

Fetch from GitHub

{{< code file="from-gh.sh" >}} go get github.com/kardianos/govendor govendor get github.com/gohugoio/hugo go install github.com/gohugoio/hugo {{< /code >}}

govendor get will fetch Hugo and all its dependent libraries to $GOPATH/src/github.com/gohugoio/hugo, and go install compiles everything into a final hugo (or hugo.exe) executable inside $GOPATH/bin/.

{{% note %}} If you are a Windows user, substitute the $HOME environment variable above with %USERPROFILE%. {{% /note %}}

macOS

Assumptions

  1. You know how to open the macOS terminal.
  2. You're running a modern 64-bit Mac.
  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.)

Pick Your Method

There are three ways to install Hugo on your Mac

  1. The Homebrew brew utility
  2. Distribution (i.e., tarball)
  3. Building from Source

There is no "best" way to install Hugo on your Mac. You should use the method that works best for your use case.

Pros and Cons

There are pros and cons to each of the aforementioned methods:

  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.

  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.

  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.

{{% note %}} Since building from source is appealing to more seasoned command line users, this guide will focus more on installing Hugo via Homebrew and Tarball. {{% /note %}}

Install Hugo with Brew

{{< youtube WvhCGlLcrF8 >}}

Step 1: Install brew if you haven't already

Go to the brew website, https://brew.sh/, and follow the directions there. The most important step is the installation from the command line:

{{< code file="install-brew.sh" >}} ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" {{< /code >}}

Step 2: Run the brew Command to Install hugo

Installing Hugo using brew is as easy as the following:

{{< code file="install-brew.sh" >}} brew install hugo {{< /code >}}

If Homebrew is working properly, you should see something similar to the following:

==> Downloading https://homebrew.bintray.com/bottles/hugo-0.21.sierra.bottle.tar.gz
######################################################################### 100.0%
==> Pouring hugo-0.21.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/hugo/0.21: 32 files, 17.4MB

{{% note "Installing the Latest Hugo with Brew" %}} Replace brew install hugo with brew install hugo --HEAD if you want the absolute latest in-development version. {{% /note %}}

brew should have updated your path to include Hugo. You can confirm by opening a new terminal window and running a few commands:

$ # show the location of the hugo executable
which hugo
/usr/local/bin/hugo

# show the installed version
ls -l $( which hugo )
lrwxr-xr-x  1 mdhender admin  30 Mar 28 22:19 /usr/local/bin/hugo -> ../Cellar/hugo/0.13_1/bin/hugo

# verify that hugo runs correctly
hugo version
Hugo Static Site Generator v0.13 BuildDate: 2015-03-09T21:34:47-05:00

Install Hugo from Tarball

Step 1: Decide on the location

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 make a copy of the entire site and update the Hugo executable.

All three locations will work for you. In the interest of brevity, this guide focuses on option #2.

Step 2: Download the Tarball

  1. Open https://github.com/gohugoio/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 choose to use a different location, you'll need to change that in the following steps.

Step 3: Confirm your download

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 for Hugo. The other file is the executable.

Step 4: Install Into Your bin Directory

# 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 open a new terminal to pick up the changes to your profile. Verify your success by running the which hugo command again.

You've successfully installed Hugo.

Build from Source on Mac

If you want to compile Hugo yourself, you'll need to install Go (aka Golang). You can install Go directly from the Go website or via Homebrew using the following command:

brew install go

Step 1: Get the Source

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:

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

{{% warning "Sometimes "Latest" = "Bugs""%}} 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. {{% /warning %}}

Step 2: Compiling

Make the directory containing the source your working directory and then fetch Hugo's dependencies:

mkdir -p src/github.com/gohugoio
ln -sf $(pwd) src/github.com/gohugoio/hugo

# set the build path for Go
export GOPATH=$(pwd)

go get

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.

Once you have properly configured your directory, you can compile Hugo using the following command:

go build -o hugo main.go

Then place the hugo executable somewhere in your $PATH. You're now ready to start using Hugo.

Windows

The following aims to be a complete guide to installing Hugo on your Windows PC.

{{< youtube G7umPCU-8xc >}}

Assumptions

  1. You will use C:\Hugo\Sites as the starting point for your new project.
  2. You will use C:\Hugo\bin to store executable files.

Set up Your Directories

You'll need a place to store the Hugo executable, your content, and the generated Hugo website:

  1. Open Windows Explorer.
  2. Create a new folder: C:\Hugo, assuming you want Hugo on your C drive, although this can go anywhere
  3. Create a subfolder in the Hugo folder: C:\Hugo\bin
  4. Create another subfolder in Hugo: C:\Hugo\Sites

Technical Users

  1. Download the latest zipped Hugo executable from Hugo Releases.
  2. Extract all contents to your ..\Hugo\bin folder.
  3. The hugo executable will be named as hugo_hugo-version_platform_arch.exe. Rename the executable to hugo.exe for ease of use.
  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.

Less-technical Users

  1. Go to the Hugo Releases page.
  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.
  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.)
  4. Move the ZIP file into your C:\Hugo\bin folder.
  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.
  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.

Now you need to add Hugo to your Windows PATH settings:

For Windows 10 Users:

  • Right click on the Start button.
  • Click on System.
  • Click on Advanced System Settings on the left.
  • Click on the Environment Variables... button on the bottom.
  • In the User variables section, find the row that starts with PATH (PATH will be all caps).
  • Double-click on PATH.
  • Click the New... button.
  • 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 Enter when you're done typing.
  • Click OK at every window to exit.

{{% note "Path Editor in Windows 10"%}} The path editor in Windows 10 was added in the large November 2015 Update. 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  Start button → Settings → System → About. See here for more.) {{% /note %}}

For Windows 7 and 8.x users:

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 or Path Editor.

Verify the Executable

Run a few commands to verify that the executable is ready to run, and then build a sample site to get started.

1. Open a Command Prompt

At the prompt, type hugo help and press the Enter key. You should see output that starts with:

hugo is the main command, used to build your Hugo site.

Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.

Complete documentation is available at https://gohugo.io/.

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 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.

At the prompt, change your directory to the Sites directory.

C:\Program Files> cd C:\Hugo\Sites
C:\Hugo\Sites>

2. Run the Command

Run the command to generate a new site. I'm using example.com as the name of the site.

C:\Hugo\Sites> hugo new site example.com

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:

C:\Hugo\Sites> cd example.com
C:\Hugo\Sites\example.com> dir
Directory of C:\hugo\sites\example.com

04/13/2015  10:44 PM    <DIR>          .
04/13/2015  10:44 PM    <DIR>          ..
04/13/2015  10:44 PM    <DIR>          archetypes
04/13/2015  10:44 PM                83 config.toml
04/13/2015  10:44 PM    <DIR>          content
04/13/2015  10:44 PM    <DIR>          data
04/13/2015  10:44 PM    <DIR>          layouts
04/13/2015  10:44 PM    <DIR>          static
               1 File(s)             83 bytes
               7 Dir(s)   6,273,331,200 bytes free

Troubleshoot Windows Installation

@dhersam has created a nice video on common issues:

{{< youtube c8fJIRNChmU >}}

Linux

Snap Package

In any of the Linux distributions that support snaps:

snap install hugo

Debian and Ubuntu

Debian and Ubuntu provide a hugo version via apt-get:

sudo apt-get install hugo

Pros

  • Native Debian/Ubuntu package maintained by Debian Developers
  • Pre-installed bash completion script and man pages

Cons

  • 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.

{{% note %}} Hugo-as-a-snap can write only inside the users $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. Use sudo apt-get 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 users $HOME directory. {{% /note %}}

Arch Linux

You can also install Hugo from the Arch Linux community repository. Applies also for derivatives such as Manjaro.

sudo pacman -Sy hugo

Fedora

Fedora provides a package for Hugo. The installation is done with the command :

sudo dnf install hugo

CentOS, and Red Hat

See the related discussion in the Hugo forums.

Upgrade Hugo

Upgrading Hugo is as easy as downloading and replacing the executable youve placed in your PATH or run brew upgrade hugo if using Homebrew.

Install Pygments (Optional)

The Hugo executable has one optional external dependency for source code highlighting (Pygments).

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.

Next Steps

Now that you've installed Hugo, read the Quick Start guide and explore the rest of the documentation. If you have questions, ask the Hugo community directly by visiting the Hugo Discussion Forum.