如何使用gohugo/hugo创建一个静态网站?


2018是静态站点生成器的一年。静态站点和动态站点之间的争论达到了一种理解水平,两种类型都被视为平等选择,这是静态站点的巨大飞跃。在不同的静态站点中,GoHugo被记录为最可靠的静态站点生成器之一。

1. windows下安装方式,点击标题进入下载页面,选择Windows版本下载

2. 安装执行,解压,切换到解压目录:

hugo new site quickstart

以上将在名为quickstart的文件夹中新的创建一个Hugo站点。

3.下面开始添加主题模板:

cd quickstart;\
git init;\
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke;\

Hugo十大主题模板

# 编辑你的 config.toml配置文件,加入Ananke主题.
echo 'theme = "ananke"' >> config.toml

4. 添加一些内容
..\hugo new posts/my-first-post.md

注意,hugo命令可能在quickstart上一级目录

5. 运行服务器:
 ..\hugo server -D

Started building sites ...
Built site for language en:
1 of 1 draft rendered
0 future content
0 expired content
1 regular pages created
8 other pages created
0 non-page files copied
1 paginator pages created
0 categories created
0 tags created
total in 18 ms
Watching for changes in /Users/bep/sites/quickstart/{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

6. 浏览器访问

//localhost:1313/
,可见到黑底白纸:My New Hugo Site