Hugo is a fast and flexible static site generator. With Hugo, you can build static websites such as landing pages, portfolio, catalogue pages within hours. If all you need is few simple pages, then you dont need the overkill of full fledged CMS or eCommerce system. There is no code overhead, you only include what you need and the result is a fast loading beautifully customized page. Hugo comes with a built in webserver and you can use this on your development environment. There are also a variety of themes to choose from.
Hugo is built in Go Programming Language but you don't need to install Go. Precompiled binaries are avaialable for macOS, Windows, Linux and FreeBSD. On macOs the installation is straight-forward by using brew:
brew install hugo
Install Hugo on Windows
1) Install chocolatey
Chocolatey is a package manager for Windows. There are two ways to install - from an administrative(elevated) command prompt or from Powershell.
To install from an elevated command prompt, open an elevated command prompt and run the below command.(Refer this article for How to open an Admin Command Prompt):
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
To install with PowerShell:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
We know this script is safe, but as a word of warning do not execute scripts without inspecting the contents.
2) Install Hugo
To install hugo using chocolatey, run the command:
choco install hugo -confirm
Verify the installation
Run the command: hugo version
C:\MyDir> hugo version Hugo Static Site Generator v0.30.2 windows/amd64 BuildDate: 2017-12-15T09:26:11Z
Install Hugo on Linux
You may either use the default package manager or install as a snap. To install Hugo on Debian and Ubuntu just run:
sudo apt-get install hugo
To install Hugo on CentOS, Red Hat Linux you may use yum
. First you have to add the repository by creating a file in /etc/yum.repos.d/ and add the following content in it. You may need root access.
# vi /etc/yum.repos.d/CentOS-hugo.repo
[daftaupe-hugo] name=Copr repo for hugo owned by daftaupe baseurl=https://copr-be.cloud.fedoraproject.org/results/daftaupe/hugo/epel-7-$basearch/ type=rpm-md skip_if_unavailable=True gpgcheck=1 gpgkey=https://copr-be.cloud.fedoraproject.org/results/daftaupe/hugo/pubkey.gpg repo_gpgcheck=0 enabled=1 enabled_metadata=1
Now you may install Hugo using yum
yum install hugo
To install Hugo on Fedora, first add the repo. As root user, create a file in /etc/yum.repos.d
and add the following lines:
vi /etc/yum.repos.d/fedora-hugo.repo
[daftaupe-hugo] name=Copr repo for hugo owned by daftaupe baseurl=https://copr-be.cloud.fedoraproject.org/results/daftaupe/hugo/fedora-$releasever-$basearch/ type=rpm-md skip_if_unavailable=True gpgcheck=1 gpgkey=https://copr-be.cloud.fedoraproject.org/results/daftaupe/hugo/pubkey.gpg repo_gpgcheck=0 enabled=1 enabled_metadata=1
Now you may install Hugo using dnf
dnf install hugo
If snaps are supported in your Linux version you may use
snap intall hugo
Installing as a snap gets you the latest version. Once installation finishes, you may verify the installation using
hugo version
To see how to build your first hugo site, read our next article How to build a site with Hugo.