
简略步骤
Hugo Quick Start
- 在 wsl 下装 Hugo
1
|
$ sudo apt install hugo
|
- TL;DR 一下 Hugo 的基础命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
$ tldr hugo
hugo
Template-based static site generator. Uses modules, components, and themes.More information: https://gohugo.io.
- Create a new Hugo site:
hugo new site {{path/to/site}}
- Create a new Hugo theme (themes may also be downloaded from https://themes.gohugo.io/):
hugo new theme {{theme_name}}
- Create a new page:
hugo new {{section_name}}/{{filename}}
- Build a site to the ./public/ directory:
hugo
- Build a site including pages that are marked as a "draft":
hugo --buildDrafts
- Build a site to a given directory:
hugo --destination {{path/to/destination}}
- Build a site, start up a webserver to serve it, and automatically reload when pages are edited:
hugo server
|
- 新建站点
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
$ hugo new site loomt
Congratulations! Your new Hugo site is created in /home/loomt/temp/loomt.
Just a few more steps and you are 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.
$ cd loomt
$ tree
.
├── archetypes
│ └── default.md
├── config.toml
├── content
├── data
├── layouts
├── static
└── themes
|
- 配置主题
$ git init
# 将皮肤作为submodule添加,以便更新
$ git submodule add https://github.com/reuixiy/hugo-theme-meme.git themes/meme # MeME,很喜欢的一个主题
$ rm config.toml && cp themes/meme/config-examples/zh-cn/config.toml config.toml #覆盖配置文件
- 发布文章
1
2
|
$ hugo new posts/HelloWorld.md #会在centent下面创建markdown文件,可以直接去编辑
Content "/home/loomt/temp/loomt/content/posts/HelloWorld.md" created
|
- 运行本地服务
1
|
$ hugo server -D --verbose # 在本地运行 -D是渲染草稿 --verbose显示详细输出
|
目前已经完成基本配置,可以访问运行在本机的站点了 🥳