为了后续能够更方便地维护网站,需要首先建立一个git项目。考虑到网络状况,这里作者使用Gitee。
$ git init
Initialized empty Git repository in D:/12 Website/AnyMcu.com/.git/
$ git remote add origin git@gitee.com:anymcu/any-mcu-on-hugo.git
$ git remote -v
origin git@gitee.com:anymcu/any-mcu-on-hugo.git (fetch)
origin git@gitee.com:anymcu/any-mcu-on-hugo.git (push)
$ git pull origin master
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), 1.33 KiB | 33.00 KiB/s, done.
From gitee.com:anymcu/any-mcu-on-hugo
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
命令:
hugo new site AnyMcu.com
执行结果:
Congratulations! Your new Hugo site is created in D:\12 Website\AnyMcu.com.
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.
将文件拷贝到git的文件夹中。
将hugo-theme-learn拷贝到文件夹themes中。
参照exampleSite中
baseURL = "/"
defaultContentLanguage = "zh"
theme = "hugo-theme-learn"
[params]
[outputs]
home = [ "HTML", "RSS", "JSON"]
[Languages]
[Languages.zh]
title = "AnyMcu.com"
weight = 3
languageName = "简体中文"
landingPageURL = "/zh"
landingPageName = "<i class='fas fa-home'></i> 首页"
[[Languages.zh.menu.shortcuts]]
name = "<i class='fas fa-fw fa-user-friends'></i> 关于"
url = "/"
weight = 11
下面就是向网站添加内容文件了。
创建两个文件,文件名为_index.md,内容为:
---
title: "首页"
---
# 欢迎使用本网站
本网站内容包括:
---
title: 第一章
weight: 1
pre: "<b>1. </b>"
chapter: true
---
### 第一章
# 标题
本章的内容简介。
两个文件分别放置在content文件夹中:
content
├── ch01
│ └── _index.md <-- /level-one
└── _index.md <-- /