iX86.MMX
  • About
  • All posts

HUGO Building Web Site - Sun, Nov 21, 2021

experience of HUGO building site.

Step1: install golang

wget https://golang.google.cn/dl/go1.17.3.linux-amd64.tar.gz
sudo rm -rf /usr/local/go #清除以前的golang相关
sudo tar -C /usr/local -xzf go1.17.3.linux-amd64.tar.gz #这样go的执行文件会在/usr/local/go/bin里
export PATH=$PATH:/usr/local/go/bin #之后编译hugo会是在$HOME/go/bin/里,需要cp 或 mv 过来,才能在系统中直接执行。

Step2: Install HUGO & Qucik start

mkdir $HOME/go/src && cd ~/go/src
git clone https://github.com/gohugoio/hugo.git
cd ~/go/src && go install –tags extended # –tags extended如果去除就不能使用sass/scss
## 视系统能力会比较长的时间进行编译,中间可能会提示gcc faile,g++ error之类,则:
sudo apt install gcc
sudo apt install g++ #之后,再:
go install –tags extended
sudo cp $HOME/go/bin/hugo /usr/local/go/bin/ #拷贝进系统路径,保证可以直接运行

Step3: Install Theme

hugo new site testWeb ##建立新站
cd testWeb
git clone https://gitlab.com/maxlefou/hugo.386.git themes/hugo.386 ##下载386theme
cp themes/hugo.386/exampleSite/config.toml ./config.toml ##拷贝theme的config.toml到website的root目录,编辑以应用
## 在testWeb根目录下使用hugo命令创建content的内容:
hugo new about.md # 创建about页面内容。
hugo new post/articleName.md #在testWeb/content/post/下创建articleName文章

Step4: Edit article with markdown

---
(这一行留空,否则会玄学failed to unmarshal YAML: yaml: line 6: could not find expected “:” )
title: “HUGO Building Web Site”
author: “i386.MMX”
date: “2021-11-21”
description: “experience of HUGO building site.”
tags: [“HUGO”,“experience”]
categories: [“Golang”,“web framework”]
(这一行留空)
---
## 上面---之间是文章属性相关内容,下面是开始正文:
其中
H1 # H1
H2 ## H2(这个是居中)
H3 ### H3(这个是>>>H3<<<)
H4 #### H4(这个是粉红色)
换行用两空格+回车,或者<br>
转义符是\

Step4: Setup config.toml

config.toml中的baseUrl一定要设置好http://domain 或 http://ip,
否则生成public文件后,主页会随着article改变。

Step5: Nginx + HUGO

修改好文章后,在testWeb根目录执行:
hugo ##会生成public/目录,即nginx站点根目录

Back to Home


iX86.MMX for HUGO | © iX86.MMX 2023 | Web Site

Linkedin GitHub GitLab