install hugo | zuhdi.org

Install Hugo /archive

Environment

  • Debian 9.7 x64
  • Go 1.12.5
  • Hugo 0.56.0-DEV

Excerpt

Pre-requisite Install Go

Log 2019 / 05

1. Install Hugo

root@athos:~# mkdir ~/src

root@athos:~# cd ~/src

root@athos:~/src# git clone https://github.com/gohugoio/hugo.git
Cloning into 'hugo'...
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 38727 (delta 8), reused 19 (delta 6), pack-reused 38700
Receiving objects: 100% (38727/38727), 69.67 MiB | 8.96 MiB/s, done.
Resolving deltas: 100% (26734/26734), done.

root@athos:~/src# cd hugo

root@athos:~/src/hugo# go install
go: finding github.com/gobwas/glob v0.2.3
go: finding github.com/tdewolff/minify/v2 v2.3.7
go: finding github.com/stretchr/testify v1.3.0
go: finding github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69
go: finding github.com/spf13/cast v1.3.0
(truncated)

root@athos:~# cd; ~/go/hugo/bin/hugo version
Hugo Static Site Generator v0.56.0-DEV linux/amd64 BuildDate: unknown

2. Configure Path

mkdir -p /opt/hugo/
mv ~/go/* /opt/hugo/
cd; rm -rf go/ src/
sed -i '/PATH/d' ~/.bashrc
echo PATH="$PATH:/opt/hugo/bin" >> ~/.bashrc
source ~/.bashrc

root@athos:~# mkdir -p /opt/hugo/

root@athos:~# mv ~/go/* /opt/hugo/

root@athos:~# cd; rm -rf go/ src/

root@athos:~# grep PATH ~/.bashrc
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/gvm/bin
:/root/.gvm/versions/go1.12.5.linux.amd64/bin

root@athos:~# sed -i '/PATH/d' ~/.bashrc

root@athos:~# echo PATH="$PATH:/opt/hugo/bin" >> ~/.bashrc

root@athos:~# source ~/.bashrc

3. Hugo gen autocomplete

root@athos:~# hugo gen autocomplete
Bash completion file for Hugo saved to /etc/bash_completion.d/hugo.sh

4. Hugo new site

root@athos:~# hugo new site athos
Congratulations! Your new Hugo site is created in /root/athos.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/, or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.

root@athos:~# ls -lF athos/
total 28
drwxr-xr-x 2 root root 4096 May 11 23:59 archetypes/
-rw-r--r-- 1 root root   82 May 11 23:59 config.toml
drwxr-xr-x 2 root root 4096 May 11 23:59 content/
drwxr-xr-x 2 root root 4096 May 11 23:59 data/
drwxr-xr-x 2 root root 4096 May 11 23:59 layouts/
drwxr-xr-x 2 root root 4096 May 11 23:59 static/
drwxr-xr-x 2 root root 4096 May 11 23:59 themes/

5. Configure Theme

root@athos:~# cd athos/

git clone \
  https://github.com/nodejh/hugo-theme-cactus-plus.git themes/hugo-theme-cactus-plus

root@athos:~/athos# git clone \
>   https://github.com/nodejh/hugo-theme-cactus-plus.git themes/hugo-theme-cactus-plus
Cloning into 'themes/hugo-theme-cactus-plus'...
remote: Enumerating objects: 713, done.
remote: Total 713 (delta 0), reused 0 (delta 0), pack-reused 713
Receiving objects: 100% (713/713), 2.17 MiB | 721.00 KiB/s, done.
Resolving deltas: 100% (370/370), done.

root@athos:~/athos# cp -r themes/hugo-theme-cactus-plus/exampleSite/* .

6. Hugo server

hugo server --bind=0.0.0.0 --port=80 \
  --baseURL=http://athos.host/

root@athos:~/athos# hugo server --bind=0.0.0.0 --port=80 \
>   --baseURL=http://athos.host/

                   | EN
+------------------+----+
  Pages            | 31
  Paginator pages  |  0
  Non-page files   |  0
  Static files     | 26
  Processed images |  0
  Aliases          |  1
  Sitemaps         |  1
  Cleaned          |  0

Total in 63 ms
Watching for changes in /root/athos/{content,data,layouts,static,themes}
Watching for config changes in /root/athos/config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://athos.host:80/ (bind address 0.0.0.0)
Press Ctrl+C to stop

7. Hugo Publish

root@athos:~/athos# hugo --baseURL=http://athos.host/

                   | EN
+------------------+----+
  Pages            | 31
  Paginator pages  |  0
  Non-page files   |  0
  Static files     | 26
  Processed images |  0
  Aliases          |  1
  Sitemaps         |  1
  Cleaned          |  0

Total in 47 ms

root@athos:~/athos# ls -lF public/
total 56
-rw-r--r-- 1 root root 3284 May 12 00:04 404.html
drwxr-xr-x 2 root root 4096 May 12 00:04 about/
drwxr-xr-x 4 root root 4096 May 12 00:04 categories/
drwxr-xr-x 2 root root 4096 May 12 00:00 css/
drwxr-xr-x 2 root root 4096 May 12 00:00 fonts/
drwxr-xr-x 2 root root 4096 May 12 00:00 images/
-rw-r--r-- 1 root root 5431 May 12 00:04 index.html
-rw-r--r-- 1 root root 2726 May 12 00:04 index.xml
drwxr-xr-x 2 root root 4096 May 12 00:00 js/
drwxr-xr-x 3 root root 4096 May 12 00:04 page/
drwxr-xr-x 6 root root 4096 May 12 00:04 posts/
-rw-r--r-- 1 root root 2488 May 12 00:04 sitemap.xml
drwxr-xr-x 8 root root 4096 May 12 00:04 tags/

Hugo. Malte Kiefer & Zuhdi Najib.