1、安装hugo

1
2
3
wget https://github.com/gohugoio/hugo/releases/download/v0.53/hugo_0.53_Linux-64bit.tar.gz
tar -xvf hugo_0.53_Linux-64bit.tar.gz
cp hugo /usr/local/bin/

2、启动hugo server

1
2
3
4
5
6
7
hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke;
echo 'theme = "ananke"' >> config.toml
hugo new posts/my-first-post.md
hugo server -D

3、hugo server启动脚本

1
/usr/local/bin/god --nohup --pidfile /var/run/hugo.pid -- /usr/local/bin/hugo server --source /data/tmp/quickstart  --baseURL https://blog.ziki.cn --appendPort=false --disableLiveReload --log --logFile /var/log/hugo.log -DEF --port1313 --bind 0.0.0.0

4、systemd

1
touch /lib/systemd/system/hugo.service
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
[Unit]
Description=Hugo server
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/var/run/hugo.pid
ExecStart=/usr/local/bin/god --nohup --pidfile /var/run/hugo.pid -- /usr/local/bin/hugo server --source /data/quickstart  --baseURL https://blog.ziki.cn --appendPort=false --disableLiveReload --log --logFile /var/log/hugo.log -DEF --port 1313 --bind 0.0.0.0
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[Unit]
Description=Hugo server
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/hugo server --minify --source /data/quickstart --baseURL https://blog.ziki.cn --appendPort=false --disableLiveReload=false --liveReloadPort=443 -DEF --port 1313 --bind 0.0.0.0
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
1
2
3
4
systemctl enable hugo
systemctl start hugo
systemctl restart hugo
systemctl status hugo

5、hugo学习